UNPKG

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