github.com/titpetric/pendulum@v0.1.180207-1512.0.20180514135826-1f399445df57/front/src/test/e2e/runner.js (about) 1 // 1. start the dev server using production config 2 process.env.NODE_ENV = 'testing' 3 var server = require('../../build/dev-server.js') 4 5 server.ready.then(() => { 6 // 2. run the nightwatch test suite against it 7 // to run in additional browsers: 8 // 1. add an entry in test/e2e/nightwatch.conf.json under "test_settings" 9 // 2. add it to the --env flag below 10 // or override the environment flag, for example: `npm run e2e -- --env chrome,firefox` 11 // For more information on Nightwatch's config file, see 12 // http://nightwatchjs.org/guide#settings-file 13 var opts = process.argv.slice(2) 14 if (opts.indexOf('--config') === -1) { 15 opts = opts.concat(['--config', 'test/e2e/nightwatch.conf.js']) 16 } 17 if (opts.indexOf('--env') === -1) { 18 opts = opts.concat(['--env', 'chrome']) 19 } 20 21 var spawn = require('cross-spawn') 22 var runner = spawn('./node_modules/.bin/nightwatch', opts, { stdio: 'inherit' }) 23 24 runner.on('exit', function (code) { 25 server.close() 26 process.exit(code) 27 }) 28 29 runner.on('error', function (err) { 30 server.close() 31 throw err 32 }) 33 })