-
Notifications
You must be signed in to change notification settings - Fork 119
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
Unable to use in successive Cypress tests #288
Comments
I fixed the A mock server is already listening on this url issue with the following implementation:
And this is how I used this on a test.
|
@tuzmusic According to the screen you have 2 WebSockets called for the first test:
So here you will have only pre-defined servers and all other WebSockets will be rejected (It stops the hot reloading there but it doesn't affect the tests. But if you want to keep it you have to add some conditions for this URL in the stub callback to create a native WebSocket at this case) |
@jrfornes Looks like your mock server is running across multiple tests until the new instance of WebsocketServerMock is created. It's better to clear all mocks in |
Problem
I am trying to use
mock-sockets
with Cypress, setting up the mock in theonBeforeLoad
hook forcy.visit()
in mybeforeEach
block. I can get one test to work but when the mock setup runs on the nextbeforeEach
I get an error thatA mock server is already listening on this url
.code under test:
(called from my React app's
componentDidiMount
)cypress tests
Here are the logs from my console:
I wonder if it has to do with that second call which is for some mystery url.
(Note: calling
cy.contains('SETTINGS').click()
at the end ofbeforeEach
somehow doesn't work, even in that first test. Even when I have my app set to start on the settings page (instead of having to click to it from inside the tests), clicking onSETTINGS
frombeforeEach
still doesn't work even though we're already there. So that's kind of weird)These full cypress logs may also be helpful:
The text was updated successfully, but these errors were encountered: