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.

Add rule to require assertion count assertion

See original GitHub issue

I always try to add a expect.assertions(<number of assertions>) call to the top of every test I write. It helps me keep track of the assertions I am using, and prevents accidental adding and removing of assertions.

I was thinking a rule that requires that assertion for every test would be nice. There is also expect.hasAssertions(), maybe that should be included in a separate rule? Or maybe not at all, I’ve never used it because it seems better to specify the count of assertions.

If you guys think this sounds good I would like to give a try at implementing it.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
giodameliocommented, Dec 31, 2017

Go for it, I was going to take a crack at it but things got busy this weekend. I’ll be looking forward to it.

On Sat, Dec 30, 2017, 21:58 tushardhole notifications@github.com wrote:

@SimenB https://github.com/simenb @giodamelio https://github.com/giodamelio As this is labeled as help wanted. If allowed, I would be happy to work on a PR for this 😄

Here is some https://github.com/tushardhole/eslint-plugin-jest/commit/b9cd260e483f8d9c343541fea8f3555393afe208 initial work I did.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jest-community/eslint-plugin-jest/issues/40#issuecomment-354587058, or mute the thread https://github.com/notifications/unsubscribe-auth/AAa9LsrbDh9LcvHOisaDT6qVHJ0cu-B2ks5tFyKbgaJpZM4RM-HW .

0reactions
SimenBcommented, Jan 9, 2018

Docs released in 21.6.1

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuring result count assertions - Pega Community
To add a new assertion, click Add expected result. Modify an existing assertion on the tab. From the Assertion type list, select Result...
Read more >
SonarQube issue "Add at least one assertion to this test case ...
This is a known limitation of the rule and we will deal with it only when we will be able to efficiently perform...
Read more >
Customize SAML Assertions - Auth0
Describes how to customize SAML assertions and the SAML and WS-Fed ... You can use rules to add more extensive or dynamic customizations...
Read more >
Working With Assertions in Functional Tests | ReadyAPI ...
Double-click the test step in the Navigator to open its editor. Run the request you are planning to assert at least once to...
Read more >
Assertion Configuration at the Asserting Party - TechDocs
Attributes statements are not required in an assertion. You can configure different types of attributes for an attribute statement. The types of ...
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