Skip to content

WS-1347: Add local command for int test - Next.js#13875

Merged
shayneahchoon merged 9 commits intolatestfrom
WS-1347-INTEGRATION
Apr 8, 2026
Merged

WS-1347: Add local command for int test - Next.js#13875
shayneahchoon merged 9 commits intolatestfrom
WS-1347-INTEGRATION

Conversation

@shayneahchoon
Copy link
Copy Markdown
Contributor

@shayneahchoon shayneahchoon commented Apr 2, 2026

Resolves JIRA: https://bbc.atlassian.net/browse/WS-1347

Summary

Adds a fallback command for integration tests and restructures promises to include an appropriate reject statement should start ups fail.

Code changes

  • Changed wait-on to a standard curl command to improve reliability.
  • yarn start on the Next.js app falls back to yarn next start -p 7081.

Testing

  1. List the steps required to test this PR.

Useful Links

);

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.

@shayneahchoon shayneahchoon marked this pull request as ready for review April 7, 2026 13:26
@shayneahchoon shayneahchoon requested a review from a team as a code owner April 7, 2026 13:26
package.json Outdated
"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 dev",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The commands between the 2 apps have different behaviours. The Express one will start the app in development mode, wheras the Next one will attempt to start it in a production build. Is that intentional?

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.

the fallbackStart command on the express app isn't needed and is pretty irrelevant. I just put it there for consistency. The main issue is to do with the NextJS app which does benefit from the added fallbackStart command as some machines don't include the standalone server bundle.

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.

Happy to change the fallbackStart on express to something else however.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I guess as well if isDev is true and yarn dev is used and fails, then the fallback will also fail because there is no production build for it to start?

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 updated it at the script level to re-run dev if the flag is selected.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sorry not really sure I follow. Where is that re-run performed?

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.

Soz, I changed it here: https://github.com/bbc/simorgh/pull/13875/changes#diff-fb36cbd39b3e10f55d949c34da923ca9621e8cf10d44c67861b623cec8295043R52

So the new flow is as follows:
Next.js normal: yarn start -> fallback to yarn next start -p 7081
Express normal: yarn start -> fallback to yarn start
dev mode for both: yarn dev -> fallback to yarn dev

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is there a danger in using dev mode for integration tests? We have snapshots that could potentially change as the build is bundled differently between dev and production, so I'd imagine Emotion class names would be different.

Copy link
Copy Markdown
Contributor Author

@shayneahchoon shayneahchoon Apr 8, 2026

Choose a reason for hiding this comment

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

I personally don't know anyone that uses dev mode at the moment, but there is a flag for it in case anyone wants to. From the way I've used it the normal commands are most reliable and consistent across on local and the github actions.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Fair enough. I'm still not entirely sure what these changes help with in regards to failed test starts.

next start doesn't work with output: standalone, so I'd be afraid we'd be doing something that isn't quite compatible with our setup:

 "next start" does not work with "output: standalone" configuration. Use "node .next/standalone/server.js" instead.

@shayneahchoon shayneahchoon merged commit 4e74eb0 into latest Apr 8, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants