run-tests.js 827 B

1234567891011121314151617181920212223242526272829303132
  1. const { spawn } = require('child_process');
  2. const { kill } = require('cross-port-killer');
  3. const env = Object.create(process.env);
  4. env.BROWSER = 'none';
  5. const startServer = spawn('npm', ['start'], {
  6. env,
  7. });
  8. startServer.stderr.on('data', (data) => {
  9. // eslint-disable-next-line
  10. console.log(data);
  11. });
  12. startServer.on('exit', () => {
  13. kill(process.env.PORT || 8000);
  14. });
  15. // eslint-disable-next-line
  16. console.log('Starting development server for e2e tests...');
  17. startServer.stdout.on('data', (data) => {
  18. if (data.toString().indexOf('The app is running at') >= 0) {
  19. // eslint-disable-next-line
  20. console.log('Development server is started, ready to run tests.');
  21. const testCmd = spawn('npm', ['test'], {
  22. stdio: 'inherit',
  23. });
  24. testCmd.on('exit', () => {
  25. startServer.kill();
  26. });
  27. }
  28. });