diff --git a/package.json b/package.json index ba3d648fe2e..3348c78f460 100644 --- a/package.json +++ b/package.json @@ -51,6 +51,7 @@ "prepare": "husky install", "preinstall": "node scripts/check-package-manager.js", "start": "NODE_ENV=production node --max-old-space-size=3500 build/server.js", + "fallbackStart": "yarn start", "stop": "./scripts/killApp.sh", "storybook": "storybook dev -p 9001 -c .storybook", "test": "yarn build && yarn test:local", diff --git a/src/integration/utils/runTests/index.js b/src/integration/utils/runTests/index.js index 45f0b335952..6351d866e38 100644 --- a/src/integration/utils/runTests/index.js +++ b/src/integration/utils/runTests/index.js @@ -45,14 +45,25 @@ const buildApp = () => const startApp = () => { const portNumber = argv.nextJS ? 7081 : 7080; const pathname = argv.nextJS ? '' : '/status'; - return new Promise(resolve => { - const child = exec( - `yarn ${ - isDev ? 'dev' : 'start' - } & ./node_modules/.bin/wait-on -t 20000 http://localhost:${portNumber}${pathname}`, - ); - child.on('exit', resolve); + const statusCommand = `sleep 20 && curl http://localhost:${portNumber}${pathname}`; + + const initialCommand = `yarn ${isDev ? 'dev' : 'start'}`; + const fallbackCommand = `yarn ${isDev ? 'dev' : 'fallbackStart'}`; + + return new Promise((resolve, reject) => { + exec(initialCommand, error => { + if (error) { + exec(fallbackCommand); + } + }); + + exec(statusCommand, error => { + if (error) { + reject(new Error('Both the initial and fallback start up failed')); + } + resolve(); + }); }); }; @@ -138,7 +149,11 @@ if (onlyRunTests) { await stopApp(); process.exit(0); }) - .catch(async () => { + .catch(async error => { + console.log( + 'Running /integration/utils/runTests/index.js returned an error => \n', + error, + ); await stopApp(); process.exit(1); }); diff --git a/ws-nextjs-app/package.json b/ws-nextjs-app/package.json index 0fcafcf6ade..a70950544c8 100644 --- a/ws-nextjs-app/package.json +++ b/ws-nextjs-app/package.json @@ -16,6 +16,7 @@ "dev": "yarn setupDevEnv && next dev -p 7081 --webpack", "dev-https": "yarn setupDevEnv && next dev -p 7081 --experimental-https --webpack", "start": "NODE_ENV=production HOSTNAME=127.0.0.1 PORT=7081 node build/standalone/ws-nextjs-app/server.js", + "fallbackStart": "next start -p 7081", "stop": "lsof -t -i:7081 | xargs kill", "test": "NODE_OPTIONS=--no-experimental-strip-types jest --ci --colors --selectProjects='Unit Tests'", "test:integration": "NODE_OPTIONS=--no-experimental-strip-types jest --ci --colors --selectProjects='Integration Tests - Canonical' --selectProjects='Integration Tests - AMP' --selectProjects='Integration Tests - Lite'",