血透系统pad前端

runner.js 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // 1. start the dev server using production config
  2. process.env.NODE_ENV = 'testing'
  3. const webpack = require('webpack')
  4. const DevServer = require('webpack-dev-server')
  5. const webpackConfig = require('../../build/webpack.prod.conf')
  6. const devConfigPromise = require('../../build/webpack.dev.conf')
  7. let server
  8. devConfigPromise.then(devConfig => {
  9. const devServerOptions = devConfig.devServer
  10. const compiler = webpack(webpackConfig)
  11. server = new DevServer(compiler, devServerOptions)
  12. const port = devServerOptions.port
  13. const host = devServerOptions.host
  14. return server.listen(port, host)
  15. })
  16. .then(() => {
  17. // 2. run the nightwatch test suite against it
  18. // to run in additional browsers:
  19. // 1. add an entry in test/e2e/nightwatch.conf.js under "test_settings"
  20. // 2. add it to the --env flag below
  21. // or override the environment flag, for example: `npm run e2e -- --env chrome,firefox`
  22. // For more information on Nightwatch's config file, see
  23. // http://nightwatchjs.org/guide#settings-file
  24. let opts = process.argv.slice(2)
  25. if (opts.indexOf('--config') === -1) {
  26. opts = opts.concat(['--config', 'test/e2e/nightwatch.conf.js'])
  27. }
  28. if (opts.indexOf('--env') === -1) {
  29. opts = opts.concat(['--env', 'chrome'])
  30. }
  31. const spawn = require('cross-spawn')
  32. const runner = spawn('./node_modules/.bin/nightwatch', opts, { stdio: 'inherit' })
  33. runner.on('exit', function (code) {
  34. server.close()
  35. process.exit(code)
  36. })
  37. runner.on('error', function (err) {
  38. server.close()
  39. throw err
  40. })
  41. })