Problem using the RestContext.delay() #1667
Replies: 1 comment 1 reply
-
There are two things that may be at play here:
Now, how to validate each. MSW does not respect the set timeoutThis can be validated if you print a timestamp before the request is made and once the response is received in your component. console.log('started:', new Date())
axios.get('...')
.then(() => console.log('received:', new Date()) Do you see the X time difference between the two timestamps where X is the delay duration you used in Axios handles its
|
Beta Was this translation helpful? Give feedback.
-
Hi all,
I have a simple react component that displays parts of the users from "https://jsonplaceholder.typicode.com/users".
When the request times out then an error message should be displayed.
=> see User.tsx in the attached sources
The component is working fine and the message is displayed. I have checked the correct functioning of the component with:
But testing this functionallity with react testing does not work.
=> The test passes if I use a locally running server with the same delay
=> The test fails if I use the Server mock
What happens:
What I would expect:
Do you have any idea why this is not working as expected?
It seems that the returned Promise from Mock Service Worker when used in node within a test is not rejected and works different from the case where a "real call" is made.
I could not find any example for this kind of testing in the internet.
Every help is wellcome.
Thanks,
Andreas
UsersAppCode.zip
Beta Was this translation helpful? Give feedback.
All reactions