[expect-expect] support chained function names
See original GitHub issue[see #418 for previous discussion]
Currently expect/expect doesn’t recognize supertest or sinon assertions. For example:
const spy = sinon.spy()
it('should work as expected', async () => {
// test code here
sinon.assert.calledOnce(spy);
});
Adding sinon (or calledOnce) into the assertFunctionNames
configuration block doesn’t get recognized, so it would be cool to:
- Be able to supply full, chained, functions to
assertFunctionNames
likesinon.assert.calledOnce
. - It would also be neat to be able to do the same but with a glob-style syntax. Something to the effect of
sinon.assert.*
or for supertest cases,request.*.expect
.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Jest functions chained onto expect() are not recognized
I am having an issue in my Node.js backend related to testing. When I try to chain a function onto .expect() , such...
Read more >Optional chaining (?.) - JavaScript - MDN Web Docs - Mozilla
The optional chaining ( ?. ) operator accesses an object's property or calls a function. If the object accessed or function called is ......
Read more >Method chaining - Wikipedia
Each method returns an object, allowing the calls to be chained together in a single statement without requiring variables to store the intermediate...
Read more >mattphillips/jest-chain: Chain Jest matchers together ... - GitHub
Use Jest's expect function the same way you would normally but with the ability to chain any matcher to another, including nested matchers...
Read more >Expect - Jest
The expect function is used every time you want to test a value. ... matcher functions, documented below, to help you test different...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yeah I was pretty sure I’d already implemented that for this exact reason 😄
While I understand why globbing sounds useful, I feel like it could be an easy footgun since it could result in non-assertion method being counted by mistake.
Plus as soon as you have “globbing” people generally expect it to work in a similar way to how it does everywhere else, so we’d have to add a new dependency for something like micromatch or globby.
None of these are a hard no, but I’ll have it on the backburner for now, and have a think.
This issue can be closed since https://github.com/jest-community/eslint-plugin-jest/commit/295ca9a6969c77fadaa1a42d76e89cae992520a6 implements this