Skip to content
Merged
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
31 changes: 23 additions & 8 deletions src/integration/utils/runTests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed wait-on to curl since I couldn't get it to work properly on local.


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();
});
});
};

Expand Down Expand Up @@ -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);
});
Expand Down
1 change: 1 addition & 0 deletions ws-nextjs-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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'",
Expand Down
Loading