This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Add option to disable delay globally, to ensure consistency in performance of tests in jest #934
Labels
You can continue the conversation there. Go to discussion →
Is your feature request related to a problem? Please describe.
I am finding that the performance of tests written with Mock Service Worker and @testing-library/react is not always consistent when running large numbers of tests (e.g. running
jest
locally or in a CI environment across a monorepo).I have found that some tests will time out before the app has fully loaded (e.g. a
waitFor
query afterrender
times out and shows a loading state still present in the DOM).Even avoiding "heavy" queries in our tests (like replacing byRole with byTestId as per testing-library/dom-testing-library#698) show this initial loading error sometimes.
Setting up MSW in setupFilesAfterEnv has improved this performance somewhat (as per https://github.com/mswjs/examples/blob/master/examples/with-jest/jest.config.js), but I'd like to be able to further future-proof the test performance and consistency by removing the "random realistic server response time" delay MSW provides on handlers. https://mswjs.io/docs/api/context/delay
Describe the solution you'd like
A global configuration setting, or a setting that we can pass to
setupServer
, that allows you to disable the delay/set a default of 0 unless it has been overridden.Describe alternatives you've considered
We could set
ctx.delay(0)
on every handler, but it's a lot of boilerplate as our code grows.Additional context
Some other folks mention performance with @testing-library/react and mock service worker here testing-library/react-testing-library#819 and here testing-library/dom-testing-library#820
The text was updated successfully, but these errors were encountered: