You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am writing a test which involves creating an item. The page I'm testing sends out a GET (/items) request to fetch all existing items and I've stubbed its response using cy.intercept. In the flow of the test, I go through the process of creating a new item and once that is done, a POST request is being sent out for the creation followed by a new GET (/items) to refetch all items. The response of the new GET request should contain the newly created item. In my test I intercept the GET request inside the beforeEach clause and then inside the it I want to be able to intercept it for the second time and this time reply with the modified response which includes the newly created item. This however doesn't work as expected cause the network tab shows that the GET request I'm trying to intercept yields the original response.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I am writing a test which involves creating an item. The page I'm testing sends out a GET (
/items
) request to fetch all existing items and I've stubbed its response using cy.intercept. In the flow of the test, I go through the process of creating a new item and once that is done, a POST request is being sent out for the creation followed by a new GET (/items
) to refetch all items. The response of the new GET request should contain the newly created item. In my test I intercept the GET request inside thebeforeEach
clause and then inside theit
I want to be able to intercept it for the second time and this time reply with the modified response which includes the newly created item. This however doesn't work as expected cause the network tab shows that the GET request I'm trying to intercept yields the original response.Beta Was this translation helpful? Give feedback.
All reactions