Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expect.hasAssertions should throw when passed arguments #3526

Merged
merged 1 commit into from
May 11, 2017

Conversation

alexlrobertson
Copy link
Contributor

  • expect.hasAssertions() should not allow useless parameters to limit confusion with expect.assertions(<n>).

Fixes #3517

Summary

expect.hasAssertions now throws an exception when is passed parameters which clarifies its difference from the similar matcher, expect.assertions(<n>).

Test plan

  • yarn test

* `expect.hasAssertions()` should not allow useless parameters to limit
  confusion with `expect.assertions(<n>)`.

Fixes jestjs#3517
@codecov-io
Copy link

Codecov Report

Merging #3526 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3526      +/-   ##
==========================================
+ Coverage   62.25%   62.26%   +<.01%     
==========================================
  Files         181      181              
  Lines        6706     6707       +1     
  Branches        6        6              
==========================================
+ Hits         4175     4176       +1     
  Misses       2528     2528              
  Partials        3        3
Impacted Files Coverage Δ
packages/jest-matchers/src/index.js 95.5% <100%> (+0.05%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 22733e4...b25edc0. Read the comment docs.

it('throws if passed parameters', () => {
jestExpect(() => {
jestExpect.hasAssertions(2);
}).toThrow();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use .toThrowError(/an error message/)? It would be nice to know what do we throw 🙂

@cpojer cpojer merged commit 0196749 into jestjs:master May 11, 2017
tushardhole pushed a commit to tushardhole/jest that referenced this pull request Aug 21, 2017
* `expect.hasAssertions()` should not allow useless parameters to limit
  confusion with `expect.assertions(<n>)`.

Fixes jestjs#3517
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

expect.hasAssertions should not accept arguments
5 participants