-
Notifications
You must be signed in to change notification settings - Fork 20
Chore: introduce Fishery as object factory and yarn dev:msw #1023
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
- adjust schema validation to make it optional - add test handlers for new alerts requests
- Also, invalidate cache for fetching fresh check alerts
- Instead of grouping by alert type, I'm displaying all alerts as separate ones - Grouping by type didn't allow to specify threshold for different percentiles
- since the alerts API is no longer in dev, I'm adding the mocks back to be able to test it - This should be improved by #850
- Also, adding loading and error states
- Add specific predefined alerts according to the check type in a single constants file - Display threshold units
a75b502
to
0b04626
Compare
The API is removing the id property for check alerts as they can be identified just by the name
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.
One thing to change then let's get this in! 🎉
src/module.ts
Outdated
if (process.env.NODE_ENV === 'development' && process.env.REACT_APP_MSW) { | ||
setupWorker(...handlers).start(); | ||
} |
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.
Just needs a small modification so it gets tree-shaken properly and doesn't affect the production bundle size:
- Move line 33 and associated imports to a file like
startServerWorker.ts
:
import { setupWorker } from 'msw';
import { handlers } from 'test/handlers';
setupWorker(...handlers).start();
- change line 33 to:
await import(
./startServiceWorker);
Then we don't include the additional 850kb overhead our mocks have 😄
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.
LGTM ❤️
Closes: #850
This PR introduces the following changes:
Fishery: Simplifies mocking data in tests, removing the need for hard-coded objects. It works alongside Faker to automatically generate dynamic test data for more flexible testing scenarios.
It defines factories for:
These factories are used to create fixtures in
src/test/fixtures/probes.ts
,src/test/fixtures/checks.ts
, andsrc/test/fixtures/checkAlerts.ts
.Mocked API responses: Adds the ability to start the app with mocked API responses. To use this, run
yarn dev:msw
. This runs a service worker that uses the same handlers as in test .Example of running the app using MSW mocked responses:
Screen.Recording.2024-12-20.at.15.44.15.mov