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

fix(expect,internal,testing): support expect.assertions #6032

Merged
merged 26 commits into from
Oct 25, 2024

Conversation

eryue0220
Copy link
Contributor

@eryue0220 eryue0220 commented Sep 22, 2024

Part of #3964, support expect.assertions api

@eryue0220 eryue0220 marked this pull request as draft September 22, 2024 16:49
@eryue0220 eryue0220 marked this pull request as ready for review September 22, 2024 17:06
@iuioiua iuioiua mentioned this pull request Sep 23, 2024
20 tasks
@iuioiua iuioiua changed the title feat(expect): support expect.assertions api feat(expect): support expect.assertions Sep 23, 2024
@kt3k kt3k changed the title feat(expect): support expect.assertions fix(expect): support expect.assertions Oct 8, 2024
@kt3k kt3k changed the title fix(expect): support expect.assertions fix(expect,internal,testing): support expect.assertions Oct 8, 2024
*/
checkAssertionCountSatisfied(): boolean {
return this.#state.assertionCount !== undefined &&
this.#state.assertionCount > this.#state.assertionTriggeredCount;
Copy link
Member

Choose a reason for hiding this comment

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

It seems in jest, expect.assertions(N) call expects exactly N assertions are made. For example, the below test file fails with the error message Expected one assertion to be called but received two assertion calls.:

test("test", () => {
  expect.assertions(1);
  expect(1).toBe(1);
  expect(2).toBe(2);
});

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll check this later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I've updated.

Copy link

codecov bot commented Oct 22, 2024

Codecov Report

Attention: Patch coverage is 49.27536% with 35 lines in your changes missing coverage. Please review.

Project coverage is 96.51%. Comparing base (5cd3b5d) to head (507ffe8).
Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
internal/assertion_state.ts 54.05% 17 Missing ⚠️
testing/_test_suite.ts 30.76% 9 Missing ⚠️
testing/bdd.ts 14.28% 6 Missing ⚠️
expect/_assertions.ts 25.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6032      +/-   ##
==========================================
- Coverage   96.58%   96.51%   -0.08%     
==========================================
  Files         536      536              
  Lines       40679    40744      +65     
  Branches     6110     6115       +5     
==========================================
+ Hits        39291    39323      +32     
- Misses       1344     1377      +33     
  Partials       44       44              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@github-actions github-actions bot removed the assert label Oct 25, 2024
Copy link
Member

@kt3k kt3k left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for your contribution!

@kt3k kt3k merged commit ed79df4 into denoland:main Oct 25, 2024
19 checks passed
@eryue0220 eryue0220 deleted the feat/expect-assertions-count-api branch October 25, 2024 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants