question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[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 like sinon.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:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
G-Rathcommented, Nov 9, 2019

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.

0reactions
folkecommented, Jan 12, 2020
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found