Commit 60822779 authored by 陈帅's avatar 陈帅

add flag to prevent multiple test

parent 608586b4
...@@ -4,6 +4,9 @@ const { kill } = require('cross-port-killer'); ...@@ -4,6 +4,9 @@ const { kill } = require('cross-port-killer');
const env = Object.create(process.env); const env = Object.create(process.env);
env.BROWSER = 'none'; env.BROWSER = 'none';
env.TEST = true; env.TEST = true;
// flag to prevent multiple test
let once = false;
const startServer = spawn(/^win/.test(process.platform) ? 'npm.cmd' : 'npm', ['start'], { const startServer = spawn(/^win/.test(process.platform) ? 'npm.cmd' : 'npm', ['start'], {
env, env,
}); });
...@@ -22,8 +25,9 @@ console.log('Starting development server for e2e tests...'); ...@@ -22,8 +25,9 @@ console.log('Starting development server for e2e tests...');
startServer.stdout.on('data', data => { startServer.stdout.on('data', data => {
// eslint-disable-next-line // eslint-disable-next-line
console.log(data.toString()); console.log(data.toString());
if (data.toString().indexOf('App running at') >= 0) { if (!once && data.toString().indexOf('App running at') >= 0) {
// eslint-disable-next-line // eslint-disable-next-line
once = true;
console.log('Development server is started, ready to run tests.'); console.log('Development server is started, ready to run tests.');
const testCmd = spawn(/^win/.test(process.platform) ? 'npm.cmd' : 'npm', ['test'], { const testCmd = spawn(/^win/.test(process.platform) ? 'npm.cmd' : 'npm', ['test'], {
stdio: 'inherit', stdio: 'inherit',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment