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(jest-each, @jest/globals): allow passing ReadonlyArray type of a table to describe.each and test.each #12297

Merged
merged 2 commits into from Feb 3, 2022

Conversation

mrazauskas
Copy link
Contributor

Fixes #12294.

Summary

As it is mentioned in the issue, typings of describe.each and test.each throw an error if a tuple with const assertion is passed as a table, e.g. describe.each([['foo'], ['bar']] as const).

Unexpected for me, but simply replacing Array with ReadonlyArray in typings solves this issue. The const assertion turns an array literal into a readonly tuple. That’s why ReadonlyArray works here.

Does ReadonlyArray fit in jest-each code? It did not compile without changes, now TS is happy. Logic did not change. So perhaps that’s alright?

Test plan

Type test are added and extended.

@codecov-commenter
Copy link

Codecov Report

Merging #12297 (ad72e3c) into main (71c1e93) will decrease coverage by 0.22%.
The diff coverage is 0.00%.

❗ Current head ad72e3c differs from pull request most recent head c93c704. Consider uploading reports for the commit c93c704 to get more accurate results

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #12297      +/-   ##
==========================================
- Coverage   67.53%   67.31%   -0.23%     
==========================================
  Files         328      328              
  Lines       17241    17297      +56     
  Branches     5065     5065              
==========================================
- Hits        11644    11643       -1     
- Misses       5564     5621      +57     
  Partials       33       33              
Impacted Files Coverage Δ
packages/jest-each/src/bind.ts 100.00% <ø> (ø)
packages/jest-types/__typechecks__/globals.test.ts 0.00% <0.00%> (ø)
packages/expect/src/utils.ts 96.09% <0.00%> (-0.49%) ⬇️

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 71c1e93...c93c704. Read the comment docs.

Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

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

Perfect, thank you!

@github-actions
Copy link

github-actions bot commented Mar 6, 2022

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 Mar 6, 2022
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.

[Bug]: Type for describe.each when importing from @jest/globals does not support const arrays
4 participants