-
Notifications
You must be signed in to change notification settings - Fork 30
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
Replace fetch-mock dependency with custom fetch mock utility #12551
Conversation
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.
CodeQL found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
c1573f6
to
c7eaea1
Compare
c7eaea1
to
8f767e2
Compare
Size Change: 0 B Total Size: 904 kB ℹ️ View Unchanged
|
f411246
to
f4e6acd
Compare
b4982f8
to
82cf850
Compare
import { GroupedNewslettersList } from './GroupedNewsletterList'; | ||
import { ManyNewsletterSignUp } from './ManyNewsletterSignUp.importable'; | ||
|
||
mockRESTCalls(); |
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.
We don't need to add mockFetch to global.fetch here, because that's done in preview.js
|
||
export const jestMockFetch = (): void => { | ||
global.fetch = jest.fn(mockFetch); | ||
}; |
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 jest specific setup for mocking fetch.
82cf850
to
2249e2a
Compare
Hello 👋! When you're ready to run Chromatic, please apply the You will need to reapply the label each time you want to run Chromatic. |
2249e2a
to
7020275
Compare
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.
🎉
7020275
to
98880a2
Compare
Seen on PROD (merged by @marjisound 9 minutes and 50 seconds ago) Please check your changes! |
Great work on this @marjisound ! |
What does this change?
This pull request removes the fetch-mock dependency and replaces it with a custom fetch mock implementation across our Jest tests and Storybook configuration.
We initially aimed to upgrade fetch-mock to address known security vulnerabilities. However, upgrading to a more recent version introduced compatibility Issues, hence we decided to get rid of this dependency
Key Changes:
mockRESTCallsInJest.ts
and Updated Storybook preview.ts file to use the new custom mockFetch for all stories.Why?
To avoid the security vulnerability fetch-mock library had in version 9