动态菜单和动态路由的 antd pro

run-tests.js 1.0KB

1234567891011121314151617181920212223242526272829303132333435363738
  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(/^win/.test(process.platform) ? 'npm.cmd' : '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. // eslint-disable-next-line
  19. console.log(data.toString());
  20. if (
  21. data.toString().indexOf('Compiled successfully') >= 0 ||
  22. data.toString().indexOf('Compiled with warnings') >= 0
  23. ) {
  24. // eslint-disable-next-line
  25. console.log('Development server is started, ready to run tests.');
  26. const testCmd = spawn(/^win/.test(process.platform) ? 'npm.cmd' : 'npm', ['test'], {
  27. stdio: 'inherit',
  28. });
  29. testCmd.on('exit', () => {
  30. startServer.kill();
  31. });
  32. }
  33. });