Description
Current behavior
CypressError: The chainer calledOnceWith was not found. Could not build assertion.
But TS types define this as allowed:
cypress/cli/types/cypress.d.ts
Line 4264 in c616af4
cypress/cli/types/cypress.d.ts
Line 4276 in c616af4
Desired behavior
Working matcher
Description
I've even started looking into fixing this but this seems to be over my head in a timeframe that I could spend on this right now.
It's not obvious to track what version are you even using because you rely on npm hoisting - your packages define very different versions of chai
, sinon
, chai-sinon
& @cypress/chai-sinon
. I believe that it would be great to:
- unify those versions
- provide at least a peer dep range where applicable
From what I've analyzed you are actually using your @cypress/chai-sinon
fork in the Cypress' public API:
and the driver package requires the v1 of that fork package, but only in its dev dep:
cypress/packages/driver/package.json
Line 16 in c1daab0
so in reality a different version gets probably loaded at runtime in the final product.
At the same time, your fork is already at v2 and it just doesn't really add those methods to the expect
object. The only ones that are handled are listed here:
https://github.com/cypress-io/sinon-chai/blob/3af9baa3b2981db8ade653bcbff58da1a1094a32/lib/sinon-chai.js#L174
Additionally links to the Sinon docs in the JSDOCs above types for all sinon-chai
method are pointing to Sinon v4 docs but I also don't believe this is actually a version that is used. Note that you link to different methods above those 2 missing methods because they have not been implemented in Sinon v4.
Test code to reproduce
const foo = cy.spy().as("foo")
setTimeout(() => {
foo({ bar: "test" })
}, 500)
cy.get("@foo").should(
"be.calledOnceWith",
Cypress.sinon.match({
bar: "test",
})
);
Versions
6.1.0
Activity
jennifer-shehane commentedon Dec 14, 2020
Yeah, the versions of each packages may be a bit off. I think @sainthkh may have been the last person to really play with the sinon typings, maybe he has some ideas.
sainthkh commentedon Dec 15, 2020
Confirmed the bug. I added them mechanically from the sinon documentation and didn't test them and thought they would naturally work. But I was wrong.
Things to do:
sainthkh commentedon Dec 30, 2020
Can anyone release the next version of
@cypress/sinon-chai
? It's blocking this issue from closing.jennifer-shehane commentedon Dec 30, 2020
Oh. Yah, we merged in the PR. Thought it would auto release 🤔
jennifer-shehane commentedon Dec 30, 2020
@sainthkh It's been released as 2.9.1
cypress-bot commentedon Jan 4, 2021
The code for this is done in cypress-io/cypress#14371, but has yet to be released.
We'll update this issue and reference the changelog when it's released.
3 remaining items