Description
Current behavior
I am migrating a project from 6.5.0 to 7.3.0 The project has a large test suite. After installing 7.3.0 many previously successful tests are failing. After investigation it appears that the behavior of cy.stub
has changed.
The existing tests have many 'module' stubs like:
const AuthProvider = require('../../../../src/providers/Auth');
cy.stub(AuthProvider, 'login', (email, password, callback) => {
callback("hard value", undefined)
})
When the test is run this stub never gets called and the default AuthProvider.login
function gets called. So the stub does nothing.
this stack overflow question demonstrates the same issue https://stackoverflow.com/questions/61944433/how-to-stub-a-module-function-with-cypress
Desired behavior
The behavior should be consistent with 6.5.0 I'm not seeing any documentation on this breaking change to cy.stub
or how to stub modules like this.
Versions
$ node -v
v10.23.0
$ npm -v
6.14.8
$ cypress -v
Cypress package version: 7.3.0
Cypress binary version: 7.3.0
Electron version: 12.0.0-beta.14
Bundled Node version: 14.15.1