runner.js 1009 B

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