Navigation Menu

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

jest/consistent-test-it does not handle describe.each properly #795

Labels
bug each support Relates to supporting the `each` method released rule: consistent-test-it

Comments

@kellyjosephprice
Copy link

Description

When configuring the rule jest/consistent-test-it, it doesn't work for describe.each calls.

To Reproduce

$ cat .eslintrc.js 
module.exports = {
  plugins: ["jest"],
  rules: {
    "jest/consistent-test-it": ["error", { fn: "test", withinDescribe: "it" }],
  },
};

$ cat package.json 
{
  "name": "jest-consistent-test-it-bug",
  "scripts": {
    "test": "eslint test.js"
  },
  "devDependencies": {
    "eslint": "^7.22.0",
    "eslint-plugin-jest": "^24.3.1"
  }
}

$ cat test.js 
var tests = [["jest/consistent-test-it", false]];

test("is valid", function () {});

describe("is valid", function () {
  it("is valid", function () {});
})

describe.each(tests)("%s", function (name, bool) {
  test("is valid, but should not be", function () {});

  it("is not valid, but should be", function () {
    expect(bool).toBe(true);
  });
});

$ npm run test

> test
> eslint test.js


/home/kelly/wsp/jest-bug/test.js
  12:3  error  Prefer using 'test' instead of 'it'  jest/consistent-test-it

✖ 1 problem (1 error, 0 warnings)
  1 error and 0 warnings potentially fixable with the `--fix` option.

npm ERR! code 1
npm ERR! path /home/kelly/wsp/jest-bug
npm ERR! command failed
npm ERR! command sh -c eslint test.js

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/kelly/.npm/_logs/2021-03-16T19_23_17_839Z-debug.log
@kellyjosephprice
Copy link
Author

Thank you!

github-actions bot pushed a commit that referenced this issue Mar 16, 2021
## [24.3.2](v24.3.1...v24.3.2) (2021-03-16)

### Bug Fixes

* **consistent-test-it:** properly handle `describe.each` ([#796](#796)) ([035bd30](035bd30)), closes [#795](#795)
@github-actions
Copy link

🎉 This issue has been resolved in version 24.3.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

This was referenced Mar 16, 2021
This was referenced Mar 17, 2021
@G-Rath G-Rath added the each support Relates to supporting the `each` method label Apr 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment