-
Notifications
You must be signed in to change notification settings - Fork 166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cypress Intercept and Wait Timeout #1065
Comments
I guess its more or less the same as the service worker api MSW (so compared to mirage it shows the requests in the network tab etc). This also doesn't work with the traditional Cypress wait. For that library they created own handlers inside https://github.com/deshiknaves/cypress-msw-interceptor I guess this miragejs should do the same and expose own handlers for it since they are using pretender. Mirage uses Pretender.js which works by monkey-patching window.fetch and window.XMLHttpRequest. |
Hi @mdbiscan . Check this issue answer maybe it could help you. |
I've walked through setting up Mirage with Cypress and it seems to be working correctly. My app loads, makes its API calls, I can follow the path through the Cypress handler into Mirage.
My application is a browser app that communicates with physical devices on an ATM machine through local API and remote API for all our products and services. It is loaded in a browser on an ATM machine, but hosted on a remote server. It can turn on a device on the machine (like a bill collector or barcode scanner) via an API call to a device server on the machine. Then the browser listens on a WebSocket port for updates from the device as customers insert their money or scan barcodes.
For testing purposes, I've created virtual devices set up with MockSocket to send data to the socket manually when needed. Both the device and remote API base URLs are the same in test and development environments to simplify using Mirage. This has worked great for manually QAing on our dev machines and testing with Jest.
When it comes to end-to-end testing with Cypress, the timing is much trickier. I need to wait for the API call to turn on a device, then have the device send a message via WebSocket, using
cy.wait
andcy.intercept
, but it seems that using Mirage is causing an issue with the alias never being called.My test looks something like this:
The alias
@startBarcodeReader
times out, but I can see in the Mirage logs that the API request has been made.The log:
Mirage: [200] POST /device/startBarcodeReader
The error:
The text was updated successfully, but these errors were encountered: