Issue with cy.intercept and component rendering #17526
Unanswered
brett-burman
asked this question in
Component Testing
Replies: 2 comments
-
I need a standalone reproduction. I can't see what you're passing in to mount. |
Beta Was this translation helpful? Give feedback.
0 replies
-
I'll see if I can put something together as I can't use the app I run the tests against. If it helps at all mount is being passed a page made up of multiple components with all API dependencies intercepted, the issue appears to be that the container that cypress mounts components to isn't completely disposed between each test and as the API has been called already it just uses the same response from the previous test. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have two tests which render the same component in different states that is controlled by the response from an API
running the test separately they work as expected running the tests sequentially in the same run and they fail it would appear a second call to the API is being ignored and the response from the first call is being used.
I am not sure if this is a bug, something I have implemented incorrectly or something else.
I am currently using cypress 7.5.0 I have tried up to 7.7.0 and get the same result.
The only work around I have found so far is to render another component in between tests
as you can see from the screen shot the route in the second test has no count
mounting another component before mounting the component under test results in the following
both routes called and the tests passing
Is there something I am missing?
test code below
I have a similar test that is a normal cypress test against a hosted site that works fine with the multiple intercepts functioning correctly and the components rendered in the correct state.
Hopefully someone can help
Thanks Brett
Beta Was this translation helpful? Give feedback.
All reactions