Question: how to make re-usable server override without killing the running time? #1401
Replies: 2 comments 8 replies
|
Hey, @SimonGodefroid. Using runtime handler overrides does not have any impact on runtime performance. It's literally a What often happens when migrating from Overall, do you have some metrics/logs to share? Can you profile your test runs and see what starts consuming more resources? It'd be great to have concrete criteria to have a productive discussion. |
|
Hey @kettanaito so I made sure indeed the things are properly awaited for and globally respect RTL guidelines. I've measured as follows: So running both branches locally the one using the renderer method with the msw handler takes over twice as much. |




Uh oh!
There was an error while loading. Please reload this page.
We are using helpers to stop using jest.mocks and replace this by re-usable server.use overrides.
e.g.
So in the tests we'd have
This works but since doing this we noticed that locally the tests are taking over twice as much time to run (because now we no longer high-jack the API calls with jest mocks). On the pipeline this causes the tests to take way longer to execute and eventually testing library selectors end up failing due to timeout.
The problem is that the right way to test is using MSW + testing library, but its impacting resources in such a way that this makes the whole pipeline very flakey.
Likewise at the moment we're removing
userrelated mocks but if we were to override another endpoint on a regular base how can we achieve this in a scalable way?We tried a different approach, in which we still have global handlers to manage API calls in a generic way but when trying to make re-usable local overrides we faced the same problem.
Testing feature x for user type a.
Testing feature x for user type b with condition 1.
Testing feature x for user type c with condition 2.
What's the correct way to handle these cases without having a dramatic impact on resource consumption and running time?
All reactions