-
Notifications
You must be signed in to change notification settings - Fork 2
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
How can I mock SignalR only for SOME Cypress tests? #9
Comments
Hey there! That would be a nice feature idea! Using this example from the README: const hubConnection = useCypressSignalRMock('testHub') ??
new HubConnectionBuilder().withUrl(`http://localhost:3000/testhub`).build(); you could do something like this in the test: Cypress.env('ENABLE_SIGNALR_MOCK', true); Then where you define the connection: const hubConnection = Cypress.env('ENABLE_SIGNALR_MOCK') ? useCypressSignalRMock('testHub') :
new HubConnectionBuilder().withUrl(`http://localhost:3000/testhub`).build() This should work but is a bit messy, I will think about a way to implement this natively in the plugin.
Why would you want to remove the dependency? |
Thanks for the quick response. I'll try that, but I agree, it is a bit messy ;)
My Cypress project and app are two distinct projects. Having Cypress dependencies in both feels wrong. Shouldn't production code try to minimize the test library dependencies. This will reduce the bundle size, etc. By the way, the doc says --save-dev, but the playground example has it as a full-fledged dependency) make it's way into production? I'm not the tree shaking expert, but doesn't having a |
Yeah that is a good point.
Hmmm, I'm honestly not sure... If you find out then let me know cause that shouldn't happen |
I have end-to-end Cypress tests that actually use the full backend with the real SignalR connection. Using your standard initialization like this:
always result in the mock being created as long as Cypress is running. This is because of these lines, correct?
How can I control the mock creation from each individual Cypress test so that it's the test that decides if SignalR is mocked or not?
That way, I could do something like this is my app code:
The text was updated successfully, but these errors were encountered: