mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
tests - start migrating mascara tests to karma
This commit is contained in:
parent
dd90e8e364
commit
56db3999ad
@ -44,13 +44,18 @@ background.on('ready', (sw) => {
|
||||
background.removeListener('updatefound', connectApp)
|
||||
connectApp(sw)
|
||||
})
|
||||
background.on('updatefound', () => window.location.reload())
|
||||
background.on('updatefound', windowReload)
|
||||
|
||||
background.startWorker()
|
||||
.then(() => {
|
||||
setTimeout(() => {
|
||||
const appContent = document.getElementById(`app-content`)
|
||||
if (!appContent.children.length) window.location.reload()
|
||||
if (!appContent.children.length) windowReload()
|
||||
}, 2000)
|
||||
})
|
||||
console.log('hello from MetaMascara ui!')
|
||||
|
||||
function windowReload() {
|
||||
if (window.METAMASK_SKIP_RELOAD) return
|
||||
window.location.reload()
|
||||
}
|
||||
|
13
mascara/test/test-ui.js
Normal file
13
mascara/test/test-ui.js
Normal file
@ -0,0 +1,13 @@
|
||||
const Helper = require('./util/mascara-test-helper.js')
|
||||
|
||||
window.METAMASK_SKIP_RELOAD = true
|
||||
window.addEventListener('load', () => {
|
||||
// inject app container
|
||||
const body = document.body
|
||||
const container = document.createElement('div')
|
||||
container.id = 'app-content'
|
||||
body.appendChild(container)
|
||||
|
||||
// start ui
|
||||
require('../src/ui.js')
|
||||
})
|
@ -1,5 +0,0 @@
|
||||
const Helper = require('./util/mascara-test-helper.js')
|
||||
|
||||
window.addEventListener('load', () => {
|
||||
require('../src/ui.js')
|
||||
})
|
@ -96,7 +96,6 @@ function startApp(){
|
||||
const container = document.createElement('div')
|
||||
container.id = 'app-content'
|
||||
body.appendChild(container)
|
||||
console.log('container', container)
|
||||
|
||||
render(
|
||||
h('.super-dev-container', [
|
||||
|
11
package.json
11
package.json
@ -12,7 +12,7 @@
|
||||
"test": "npm run lint && npm run test-unit && npm run test-integration",
|
||||
"test-unit": "METAMASK_ENV=test mocha --require test/helper.js --recursive \"test/unit/**/*.js\"",
|
||||
"single-test": "METAMASK_ENV=test mocha --require test/helper.js",
|
||||
"test-integration": "npm run buildMock && npm run buildCiUnits && karma start",
|
||||
"test-integration": "npm run buildMock && npm run buildCiUnits && karma start test/together.conf.js",
|
||||
"test-coverage": "nyc npm run test-unit && npm run coveralls-upload",
|
||||
"coveralls-upload": "if [ $COVERALLS_REPO_TOKEN ]; then nyc report --reporter=text-lcov | coveralls; fi",
|
||||
"ci": "npm run lint && npm run test-coverage && npm run test-integration",
|
||||
@ -27,10 +27,11 @@
|
||||
"generateNotice": "node notices/notice-generator.js",
|
||||
"deleteNotice": "node notices/notice-delete.js",
|
||||
"mascara": "node ./mascara/example/server",
|
||||
"buildMascaraCi": "browserify mascara/test/window-load.js -o mascara/test/bundle.js",
|
||||
"buildMascaraSWCi": "browserify mascara/src/background.js -o mascara/test/background.js",
|
||||
"mascaraCi": "npm run buildMascaraCi && npm run buildMascaraSWCi && node mascara/test/index.js",
|
||||
"testMascara": "cd mascara/test && npm run mascaraCi && testem ci -P 3"
|
||||
"testMascara": "npm run buildMascara && karma start test/mascara.conf.js",
|
||||
"buildMascara": "npm run buildMascaraUi && npm run buildMascaraBackground && npm run buildMascaraTests",
|
||||
"buildMascaraUi": "browserify mascara/test/test-ui.js -o mascara/test/ui-bundle.js",
|
||||
"buildMascaraBackground": "browserify mascara/src/background.js -o mascara/test/background.js",
|
||||
"buildMascaraTests": "browserify test/integration/lib/first-time.js -o mascara/test/test-bundle.js"
|
||||
},
|
||||
"browserify": {
|
||||
"transform": [
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Generated on Mon Sep 11 2017 18:45:48 GMT-0700 (PDT)
|
||||
|
||||
module.exports = function(config) {
|
||||
config.set({
|
||||
return {
|
||||
// base path that will be used to resolve all patterns (eg. files, exclude)
|
||||
basePath: process.cwd(),
|
||||
|
||||
@ -16,9 +16,7 @@ module.exports = function(config) {
|
||||
|
||||
// list of files / patterns to load in the browser
|
||||
files: [
|
||||
'development/bundle.js',
|
||||
'test/integration/jquery-3.1.0.min.js',
|
||||
'test/integration/bundle.js',
|
||||
{ pattern: 'dist/chrome/images/**/*.*', watched: false, included: false, served: true },
|
||||
{ pattern: 'dist/chrome/fonts/**/*.*', watched: false, included: false, served: true },
|
||||
],
|
||||
@ -57,5 +55,5 @@ module.exports = function(config) {
|
||||
// Concurrency level
|
||||
// how many browser should be started simultaneous
|
||||
concurrency: Infinity
|
||||
})
|
||||
}
|
||||
}
|
14
test/mascara.conf.js
Normal file
14
test/mascara.conf.js
Normal file
@ -0,0 +1,14 @@
|
||||
const getBaseConfig = require('./base.conf.js')
|
||||
|
||||
module.exports = function(config) {
|
||||
const settings = getBaseConfig(config)
|
||||
settings.files.push('mascara/test/ui-bundle.js')
|
||||
settings.files.push('mascara/test/test-bundle.js')
|
||||
// settings.files.push('test/integration/bundle.js')
|
||||
settings.files.push({ pattern: 'mascara/test/background.js', watched: false, included: false, served: true }),
|
||||
// /background.js
|
||||
|
||||
settings.proxies['/background.js'] = '/base/mascara/test/background.js'
|
||||
|
||||
config.set(settings)
|
||||
}
|
8
test/together.conf.js
Normal file
8
test/together.conf.js
Normal file
@ -0,0 +1,8 @@
|
||||
const getBaseConfig = require('./base.conf.js')
|
||||
|
||||
module.exports = function(config) {
|
||||
const settings = getBaseConfig(config)
|
||||
settings.files.push('development/bundle.js')
|
||||
settings.files.push('test/integration/bundle.js')
|
||||
config.set(settings)
|
||||
}
|
Loading…
Reference in New Issue
Block a user