-
Notifications
You must be signed in to change notification settings - Fork 3
[NextJS] fix frontend tests outside of main workspace
#1527
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
main dir
main dirmain workspace
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was deleted in nextjs branch; i've just reinstated it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is one of the bigger changes. Basically, react-router came with MemoryRouter specifically designed for uses in tests. NextJS does not have anything like that builtin.
next-router-mock is a community library for mocking next/router, but it's designed for the Pages router. There's an open issue for using it with the App router, but that takes a little effort.
| ? getEmbedlyUrl(resource, size, isMedia) | ||
| : DEFAULT_RESOURCE_IMG | ||
| } | ||
| src={resource.image?.url ? resource.image?.url : DEFAULT_RESOURCE_IMG} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jonkafton Did you mean to use both embedly and NextJS Image component here? I've switched it to just NextJS for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a fallback in getEmbedlyUrl in the Storybook branch to just use the image URL if the env var is not set:
if (!process.env.NEXT_PUBLIC_EMBEDLY_KEY!) {
return resource.image!.url!
}
Writing this I realize that where we use the nextjs/image component we'd be pulling an Embedly image via the Next.js image optimizer, so yeh - we don't want to do that!
35c32c4 to
4dfc6e5
Compare
ad0fdb9 to
0f21199
Compare
7b53db4 to
cf71f03
Compare
* add util getByImageSrc * remove main + mit-learn jest configs (for now) * restore mock request example * use NEXT_PUBLIC_MITOL_API_BASE_URL * fix failing image related tests * fix most remaining ol-components tests * fix remaining nextjs tests in ol-components * fix some TS errors, move mock * disable ci typecheck task * better comment * sometimes TS is frustrating * re-enable tests * run tests w specific env var * remove sharp * formatting fix * dedupe types/react * enable build-storybook on ci
* add util getByImageSrc * remove main + mit-learn jest configs (for now) * restore mock request example * use NEXT_PUBLIC_MITOL_API_BASE_URL * fix failing image related tests * fix most remaining ol-components tests * fix remaining nextjs tests in ol-components * fix some TS errors, move mock * disable ci typecheck task * better comment * sometimes TS is frustrating * re-enable tests * run tests w specific env var * remove sharp * formatting fix * dedupe types/react * enable build-storybook on ci
* add util getByImageSrc * remove main + mit-learn jest configs (for now) * restore mock request example * use NEXT_PUBLIC_MITOL_API_BASE_URL * fix failing image related tests * fix most remaining ol-components tests * fix remaining nextjs tests in ol-components * fix some TS errors, move mock * disable ci typecheck task * better comment * sometimes TS is frustrating * re-enable tests * run tests w specific env var * remove sharp * formatting fix * dedupe types/react * enable build-storybook on ci
* add util getByImageSrc * remove main + mit-learn jest configs (for now) * restore mock request example * use NEXT_PUBLIC_MITOL_API_BASE_URL * fix failing image related tests * fix most remaining ol-components tests * fix remaining nextjs tests in ol-components * fix some TS errors, move mock * disable ci typecheck task * better comment * sometimes TS is frustrating * re-enable tests * run tests w specific env var * remove sharp * formatting fix * dedupe types/react * enable build-storybook on ci
* add util getByImageSrc * remove main + mit-learn jest configs (for now) * restore mock request example * use NEXT_PUBLIC_MITOL_API_BASE_URL * fix failing image related tests * fix most remaining ol-components tests * fix remaining nextjs tests in ol-components * fix some TS errors, move mock * disable ci typecheck task * better comment * sometimes TS is frustrating * re-enable tests * run tests w specific env var * remove sharp * formatting fix * dedupe types/react * enable build-storybook on ci
* add util getByImageSrc * remove main + mit-learn jest configs (for now) * restore mock request example * use NEXT_PUBLIC_MITOL_API_BASE_URL * fix failing image related tests * fix most remaining ol-components tests * fix remaining nextjs tests in ol-components * fix some TS errors, move mock * disable ci typecheck task * better comment * sometimes TS is frustrating * re-enable tests * run tests w specific env var * remove sharp * formatting fix * dedupe types/react * enable build-storybook on ci
* add util getByImageSrc * remove main + mit-learn jest configs (for now) * restore mock request example * use NEXT_PUBLIC_MITOL_API_BASE_URL * fix failing image related tests * fix most remaining ol-components tests * fix remaining nextjs tests in ol-components * fix some TS errors, move mock * disable ci typecheck task * better comment * sometimes TS is frustrating * re-enable tests * run tests w specific env var * remove sharp * formatting fix * dedupe types/react * enable build-storybook on ci
* add util getByImageSrc * remove main + mit-learn jest configs (for now) * restore mock request example * use NEXT_PUBLIC_MITOL_API_BASE_URL * fix failing image related tests * fix most remaining ol-components tests * fix remaining nextjs tests in ol-components * fix some TS errors, move mock * disable ci typecheck task * better comment * sometimes TS is frustrating * re-enable tests * run tests w specific env var * remove sharp * formatting fix * dedupe types/react * enable build-storybook on ci
* add util getByImageSrc * remove main + mit-learn jest configs (for now) * restore mock request example * use NEXT_PUBLIC_MITOL_API_BASE_URL * fix failing image related tests * fix most remaining ol-components tests * fix remaining nextjs tests in ol-components * fix some TS errors, move mock * disable ci typecheck task * better comment * sometimes TS is frustrating * re-enable tests * run tests w specific env var * remove sharp * formatting fix * dedupe types/react * enable build-storybook on ci
What are the relevant tickets?
Toward https://github.com/mitodl/hq/issues/5395
Description (What does it do?)
This PR fixes tests outside of the
main(nextjs) workspace. Primarily this was:process.env.var_nameHow can this be tested?
yarn testlocally.