runner.js 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. // 1. start the dev server using production config
  2. process.env.NODE_ENV = 'testing'
  3. var server = require('../../build/dev-server.js')
  4. server.ready.then(() => {
  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
  12. var opts = process.argv.slice(2)
  13. if (opts.indexOf('--config') === -1) {
  14. opts = opts.concat(['--config', 'test/e2e/nightwatch.conf.js'])
  15. }
  16. if (opts.indexOf('--env') === -1) {
  17. opts = opts.concat(['--env', 'chrome'])
  18. }
  19. var spawn = require('cross-spawn')
  20. var runner = spawn('./node_modules/.bin/nightwatch', opts, { stdio: 'inherit' })
  21. runner.on('exit', function (code) {
  22. server.close()
  23. process.exit(code)
  24. })
  25. runner.on('error', function (err) {
  26. server.close()
  27. throw err
  28. })
  29. })