tests - start migrating mascara tests to karma

feature/default_network_editable
kumavis 7 years ago
parent dd90e8e364
commit 56db3999ad
  1. 9
      mascara/src/ui.js
  2. 13
      mascara/test/test-ui.js
  3. 5
      mascara/test/window-load.js
  4. 1
      mock-dev.js
  5. 11
      package.json
  6. 6
      test/base.conf.js
  7. 14
      test/mascara.conf.js
  8. 8
      test/together.conf.js

@ -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()
}

@ -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', [

@ -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
})
}
}

@ -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)
}

@ -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…
Cancel
Save