I have one scenario where I have to click on one link, that opens a new tab/window, As cypress does not support multiple tabs, I have found below workaround but its not working, It opens the new tab, but not able to switch the new tab and my test is failing with the error : expected redirect to have been
Tag: stub
How to set a Sinon spy for a dependency defined in a class, rather than a Sinon stub?
I am unit testing a method defined in a module, which itself calls a dependency defined in a second module. I want to set a spy for the method-under-test’s call to the dependency, using the Sinon package. How do I do that? I’ve seen Sinon’s page on mocking the dependency of a module (see here), and have been able to
Mocking methods of a JavaScript object created within a function
I’ve written a JavaScript function that creates an object from a require()’d library, and then uses it. That seems to be causing me trouble when I try to write tests for it because I don’t seem to have a good way to gain control over that object and create mocks of its methods to test the behavior of my function.
How to return based on actual arguments being sent?
Let’s say we have a function with two arguments. It’s being called many times with different arguments on every call. So, its impossible to stub it with withArgs option. I want to write a stub function which will check the actual arguments being passed (args1, args2) and return a static response with a switch case. Something on the following lines: