During an e2e or integration test, we should throw a specific error message when:
- a value is returned to a callback function
- in either a mocha
it test or in a custom command
- and a
cy command was invoked.
We're going to opt for a stricter API up front contract instead of being magical behind the scenes and forcing return values unbeknownst to the developer.
The following situations should throw:
Cypress.Commands.addParent("foo", function(){
cy.get("body").should("have.class", "foo")
return "foobarbaz"
})
it("should throw", function(){
cy.get("body").should("have.class", "foo")
// currently Cypress detects this and forcibly
// returns 'cy'. Instead we should throw.
return "foobarbaz"
})
it("should also throw", function(){
cy.foo()
})
it("does not throw", function(){
// this is okay since no cy commands were invoked!
expect(true).to.be.true
})
During an
e2eorintegrationtest, we should throw a specific error message when:ittest or in a custom commandcycommand was invoked.We're going to opt for a stricter API up front contract instead of being magical behind the scenes and forcing return values unbeknownst to the developer.
The following situations should throw: