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

test.each no-done-callback false positive in version 24.1.2 #710

Closed
voda opened this issue Nov 12, 2020 · 3 comments · Fixed by #713
Closed

test.each no-done-callback false positive in version 24.1.2 #710

voda opened this issue Nov 12, 2020 · 3 comments · Fixed by #713
Labels
bug each support Relates to supporting the `each` method released

Comments

@voda
Copy link

voda commented Nov 12, 2020

Very similar to #709, but there is still a false positive when the test function has 2 arguments.

Plugin version: 24.1.2
Last working version: 24.1.0
Rule jest/no-done-callback has false positives with test.each

it.each([
	[1, 2],
	[2, 4],
	[3, 6],
])('.double(%i)', async (a: number, expected: number) => {
	expect(2 * a).toBe(expected);
});
@jsaguet
Copy link

jsaguet commented Nov 12, 2020

I just had the same issue.

After having a quick look at the rule implementation, it seems the logic is to check the number of arguments of the test function.

But for test.each / it.each used with a table, just checking the number of arguments of the function will never work.
I think the only way to enforce this rule in this case is to check if the last argument is actually called in the function block statement.

@voda
Copy link
Author

voda commented Nov 12, 2020

I think the only way to enforce this rule in this case is to check if the last argument is actually called in the function block statement.

The list of test cases can also contain a callback, so I don't think that would work.

it.each([
	[1, () => 2],
])(...);

I think jest is also checking the number of arguments: https://github.com/facebook/jest/blob/f9132f9106e3f1b3ae6f81d1f36222055c3fe111/packages/jest-each/src/bind.ts#L81-L83

github-actions bot pushed a commit that referenced this issue Nov 12, 2020
## [24.1.3](v24.1.2...v24.1.3) (2020-11-12)

### Bug Fixes

* revert change causing regressions for test.each ([#713](#713)) ([7c8d75a](7c8d75a)), closes [#710](#710) [#711](#711)
@github-actions
Copy link

🎉 This issue has been resolved in version 24.1.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

This was referenced Mar 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment