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
it('shows name after successful fetch',()=>{cy.intercept('GET','**/.data/me',{statusCode: 200,body: {name: 'John'}}).as('getData1')cy.mount(<App/>)cy.contains('Hello, John').should('be.visible')})
But the test failing in UI with the "Timed out retrying after 4000ms: Expected to find content: 'Hello, John' but never did." error, because Cypress failed to mock the request.
According to DevTools, it was successfully passed to http://localhost:5173/__cypress/iframes/.data/me and response contains some cypress internal code.
Desired behavior
I'd expect that fetches without leading slash should be mocked. I understand that it's a bad pattern, but some apps use it, and it may be impossible to change this logic on the app side.
Current behavior
I have a react component containing the code:
My component tests has the intercept:
But the test failing in UI with the "Timed out retrying after 4000ms: Expected to find content: 'Hello, John' but never did." error, because Cypress failed to mock the request.
According to DevTools, it was successfully passed to
http://localhost:5173/__cypress/iframes/.data/me
and response contains some cypress internal code.Desired behavior
I'd expect that fetches without leading slash should be mocked. I understand that it's a bad pattern, but some apps use it, and it may be impossible to change this logic on the app side.
Test code to reproduce
I created a project to reproduce the issue: https://github.com/DeniDoman/vite-react-starter
Component code: https://github.com/DeniDoman/vite-react-starter/blob/main/src/App.tsx
Test code: https://github.com/DeniDoman/vite-react-starter/blob/main/src/App.cy.tsx
Cypress Version
14.1.0
Node version
v18.19.1
Operating System
macOS 14.5 (23F79)
The text was updated successfully, but these errors were encountered: