From 071371867e435bd2aae9e133032d9488667ecc45 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Thu, 12 Nov 2020 14:13:55 +0100 Subject: [PATCH 1/5] Revert "fix(no-done-callback): fix regression with it.each (#708)" This reverts commit 2f032f8d890e3717359d099b1e93e0cc6b52996a. --- src/rules/__tests__/no-done-callback.test.ts | 44 -------------------- src/rules/no-done-callback.ts | 23 ++-------- 2 files changed, 4 insertions(+), 63 deletions(-) diff --git a/src/rules/__tests__/no-done-callback.test.ts b/src/rules/__tests__/no-done-callback.test.ts index d91c19d28..f4fc63903 100644 --- a/src/rules/__tests__/no-done-callback.test.ts +++ b/src/rules/__tests__/no-done-callback.test.ts @@ -15,10 +15,6 @@ ruleTester.run('no-done-callback', rule, { 'test("something", () => {})', 'test("something", async () => {})', 'test("something", function() {})', - 'test.each``("something", ({ a, b }) => {})', - 'test.each()("something", ({ a, b }) => {})', - 'it.each()("something", ({ a, b }) => {})', - 'it.each``("something", ({ a, b }) => {})', 'test("something", async function () {})', 'test("something", someArg)', 'beforeEach(() => {})', @@ -389,45 +385,5 @@ ruleTester.run('no-done-callback', rule, { }, ], }, - { - code: 'test.each``("something", ({ a, b }, done) => { done(); })', - errors: [ - { - messageId: 'noDoneCallback', - line: 1, - column: 37, - }, - ], - }, - { - code: 'test.each()("something", ({ a, b }, done) => { done(); })', - errors: [ - { - messageId: 'noDoneCallback', - line: 1, - column: 37, - }, - ], - }, - { - code: 'it.each``("something", ({ a, b }, done) => { done(); })', - errors: [ - { - messageId: 'noDoneCallback', - line: 1, - column: 35, - }, - ], - }, - { - code: 'it.each()("something", ({ a, b }, done) => { done(); })', - errors: [ - { - messageId: 'noDoneCallback', - line: 1, - column: 35, - }, - ], - }, ], }); diff --git a/src/rules/no-done-callback.ts b/src/rules/no-done-callback.ts index 345722dae..70fde6caa 100644 --- a/src/rules/no-done-callback.ts +++ b/src/rules/no-done-callback.ts @@ -2,22 +2,11 @@ import { AST_NODE_TYPES, TSESTree, } from '@typescript-eslint/experimental-utils'; -import { - createRule, - getNodeName, - isFunction, - isHook, - isTestCase, -} from './utils'; +import { createRule, isFunction, isHook, isTestCase } from './utils'; const findCallbackArg = ( node: TSESTree.CallExpression, - isJestEach: boolean, ): TSESTree.CallExpression['arguments'][0] | null => { - if (isJestEach) { - return node.arguments[1]; - } - if (isHook(node) && node.arguments.length >= 1) { return node.arguments[0]; } @@ -52,21 +41,17 @@ export default createRule({ create(context) { return { CallExpression(node) { - // done is the second argument for it.each, not the first - const isJestEach = getNodeName(node.callee)?.endsWith('.each') ?? false; - - const callback = findCallbackArg(node, isJestEach); - const callbackArgIndex = Number(isJestEach); + const callback = findCallbackArg(node); if ( !callback || !isFunction(callback) || - callback.params.length !== 1 + callbackArgIndex + callback.params.length !== 1 ) { return; } - const argument = callback.params[callbackArgIndex]; + const [argument] = callback.params; if (argument.type !== AST_NODE_TYPES.Identifier) { context.report({ From 5cc1d1b6ab54df37f25c4b853c2916edcf89f681 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Thu, 12 Nov 2020 14:14:06 +0100 Subject: [PATCH 2/5] Revert "fix: improve support for it.each involving tagged template literals (#701)" This reverts commit 2341814060b38c55728c0b456d7b432f1e0e1a11. --- .../__tests__/consistent-test-it.test.ts | 72 ------------------- src/rules/__tests__/no-disabled-tests.test.ts | 33 --------- .../__tests__/no-standalone-expect.test.ts | 4 -- src/rules/__tests__/no-test-prefixes.test.ts | 60 ---------------- src/rules/consistent-test-it.ts | 9 +-- src/rules/no-disabled-tests.ts | 7 -- src/rules/no-test-prefixes.ts | 14 +--- src/rules/utils.ts | 16 +---- 8 files changed, 6 insertions(+), 209 deletions(-) diff --git a/src/rules/__tests__/consistent-test-it.test.ts b/src/rules/__tests__/consistent-test-it.test.ts index 75afdeef6..2c96ea310 100644 --- a/src/rules/__tests__/consistent-test-it.test.ts +++ b/src/rules/__tests__/consistent-test-it.test.ts @@ -32,14 +32,6 @@ ruleTester.run('consistent-test-it with fn=test', rule, { code: 'xtest("foo")', options: [{ fn: TestCaseName.test }], }, - { - code: 'test.each([])("foo")', - options: [{ fn: TestCaseName.test }], - }, - { - code: 'test.each``("foo")', - options: [{ fn: TestCaseName.test }], - }, { code: 'describe("suite", () => { test("foo") })', options: [{ fn: TestCaseName.test }], @@ -130,34 +122,6 @@ ruleTester.run('consistent-test-it with fn=test', rule, { }, ], }, - { - code: 'it.each([])("foo")', - output: 'test.each([])("foo")', - options: [{ fn: TestCaseName.test }], - errors: [ - { - messageId: 'consistentMethod', - data: { - testKeyword: TestCaseName.test, - oppositeTestKeyword: TestCaseName.it, - }, - }, - ], - }, - { - code: 'it.each``("foo")', - output: 'test.each``("foo")', - options: [{ fn: TestCaseName.test }], - errors: [ - { - messageId: 'consistentMethod', - data: { - testKeyword: TestCaseName.test, - oppositeTestKeyword: TestCaseName.it, - }, - }, - ], - }, { code: 'describe("suite", () => { it("foo") })', output: 'describe("suite", () => { test("foo") })', @@ -201,14 +165,6 @@ ruleTester.run('consistent-test-it with fn=it', rule, { code: 'it.concurrent("foo")', options: [{ fn: TestCaseName.it }], }, - { - code: 'it.each([])("foo")', - options: [{ fn: TestCaseName.it }], - }, - { - code: 'it.each``("foo")', - options: [{ fn: TestCaseName.it }], - }, { code: 'describe("suite", () => { it("foo") })', options: [{ fn: TestCaseName.it }], @@ -285,34 +241,6 @@ ruleTester.run('consistent-test-it with fn=it', rule, { }, ], }, - { - code: 'test.each([])("foo")', - output: 'it.each([])("foo")', - options: [{ fn: TestCaseName.it }], - errors: [ - { - messageId: 'consistentMethod', - data: { - testKeyword: TestCaseName.it, - oppositeTestKeyword: TestCaseName.test, - }, - }, - ], - }, - { - code: 'test.each``("foo")', - output: 'it.each``("foo")', - options: [{ fn: TestCaseName.it }], - errors: [ - { - messageId: 'consistentMethod', - data: { - testKeyword: TestCaseName.it, - oppositeTestKeyword: TestCaseName.test, - }, - }, - ], - }, { code: 'describe("suite", () => { test("foo") })', output: 'describe("suite", () => { it("foo") })', diff --git a/src/rules/__tests__/no-disabled-tests.test.ts b/src/rules/__tests__/no-disabled-tests.test.ts index 34a847698..3f317c0be 100644 --- a/src/rules/__tests__/no-disabled-tests.test.ts +++ b/src/rules/__tests__/no-disabled-tests.test.ts @@ -16,7 +16,6 @@ ruleTester.run('no-disabled-tests', rule, { 'it("foo", function () {})', 'describe.only("foo", function () {})', 'it.only("foo", function () {})', - 'it.each("foo", () => {})', 'it.concurrent("foo", function () {})', 'test("foo", function () {})', 'test.only("foo", function () {})', @@ -88,22 +87,6 @@ ruleTester.run('no-disabled-tests', rule, { code: 'test.skip("foo", function () {})', errors: [{ messageId: 'skippedTest', column: 1, line: 1 }], }, - { - code: 'it.skip.each``("foo", function () {})', - errors: [{ messageId: 'skippedTest', column: 1, line: 1 }], - }, - { - code: 'test.skip.each``("foo", function () {})', - errors: [{ messageId: 'skippedTest', column: 1, line: 1 }], - }, - { - code: 'it.skip.each([])("foo", function () {})', - errors: [{ messageId: 'skippedTest', column: 1, line: 1 }], - }, - { - code: 'test.skip.each([])("foo", function () {})', - errors: [{ messageId: 'skippedTest', column: 1, line: 1 }], - }, { code: 'test.concurrent.skip("foo", function () {})', errors: [{ messageId: 'skippedTest', column: 1, line: 1 }], @@ -124,22 +107,6 @@ ruleTester.run('no-disabled-tests', rule, { code: 'xtest("foo", function () {})', errors: [{ messageId: 'disabledTest', column: 1, line: 1 }], }, - { - code: 'xit.each``("foo", function () {})', - errors: [{ messageId: 'skippedTest', column: 1, line: 1 }], - }, - { - code: 'xtest.each``("foo", function () {})', - errors: [{ messageId: 'skippedTest', column: 1, line: 1 }], - }, - { - code: 'xit.each([])("foo", function () {})', - errors: [{ messageId: 'skippedTest', column: 1, line: 1 }], - }, - { - code: 'xtest.each([])("foo", function () {})', - errors: [{ messageId: 'skippedTest', column: 1, line: 1 }], - }, { code: 'it("has title but no callback")', errors: [{ messageId: 'missingFunction', column: 1, line: 1 }], diff --git a/src/rules/__tests__/no-standalone-expect.test.ts b/src/rules/__tests__/no-standalone-expect.test.ts index 7b60f524c..7b4944545 100644 --- a/src/rules/__tests__/no-standalone-expect.test.ts +++ b/src/rules/__tests__/no-standalone-expect.test.ts @@ -57,10 +57,6 @@ ruleTester.run('no-standalone-expect', rule, { }, ], invalid: [ - { - code: "(() => {})('testing', () => expect(true))", - errors: [{ endColumn: 41, column: 29, messageId: 'unexpectedExpect' }], - }, { code: ` describe('scenario', () => { diff --git a/src/rules/__tests__/no-test-prefixes.test.ts b/src/rules/__tests__/no-test-prefixes.test.ts index 731fe74fa..330ad0aaa 100644 --- a/src/rules/__tests__/no-test-prefixes.test.ts +++ b/src/rules/__tests__/no-test-prefixes.test.ts @@ -12,18 +12,8 @@ ruleTester.run('no-test-prefixes', rule, { 'test.concurrent("foo", function () {})', 'describe.only("foo", function () {})', 'it.only("foo", function () {})', - 'it.each()("foo", function () {})', - { - code: 'it.each``("foo", function () {})', - parserOptions: { ecmaVersion: 6 }, - }, 'it.concurrent.only("foo", function () {})', 'test.only("foo", function () {})', - 'test.each()("foo", function () {})', - { - code: 'test.each``("foo", function () {})', - parserOptions: { ecmaVersion: 6 }, - }, 'test.concurrent.only("foo", function () {})', 'describe.skip("foo", function () {})', 'it.skip("foo", function () {})', @@ -106,55 +96,5 @@ ruleTester.run('no-test-prefixes', rule, { }, ], }, - { - code: 'xit.each``("foo", function () {})', - output: 'it.skip.each``("foo", function () {})', - parserOptions: { ecmaVersion: 6 }, - errors: [ - { - messageId: 'usePreferredName', - data: { preferredNodeName: 'it.skip.each' }, - column: 1, - line: 1, - }, - ], - }, - { - code: 'xtest.each``("foo", function () {})', - output: 'test.skip.each``("foo", function () {})', - parserOptions: { ecmaVersion: 6 }, - errors: [ - { - messageId: 'usePreferredName', - data: { preferredNodeName: 'test.skip.each' }, - column: 1, - line: 1, - }, - ], - }, - { - code: 'xit.each([])("foo", function () {})', - output: 'it.skip.each([])("foo", function () {})', - errors: [ - { - messageId: 'usePreferredName', - data: { preferredNodeName: 'it.skip.each' }, - column: 1, - line: 1, - }, - ], - }, - { - code: 'xtest.each([])("foo", function () {})', - output: 'test.skip.each([])("foo", function () {})', - errors: [ - { - messageId: 'usePreferredName', - data: { preferredNodeName: 'test.skip.each' }, - column: 1, - line: 1, - }, - ], - }, ], }); diff --git a/src/rules/consistent-test-it.ts b/src/rules/consistent-test-it.ts index 75cc9025e..cfb204010 100644 --- a/src/rules/consistent-test-it.ts +++ b/src/rules/consistent-test-it.ts @@ -82,11 +82,6 @@ export default createRule< describeNestingLevel++; } - const funcNode = - node.callee.type === AST_NODE_TYPES.TaggedTemplateExpression - ? node.callee.tag - : node.callee; - if ( isTestCase(node) && describeNestingLevel === 0 && @@ -98,7 +93,7 @@ export default createRule< messageId: 'consistentMethod', node: node.callee, data: { testKeyword, oppositeTestKeyword }, - fix: buildFixer(funcNode, nodeName, testKeyword), + fix: buildFixer(node.callee, nodeName, testKeyword), }); } @@ -115,7 +110,7 @@ export default createRule< messageId: 'consistentMethodWithinDescribe', node: node.callee, data: { testKeywordWithinDescribe, oppositeTestKeyword }, - fix: buildFixer(funcNode, nodeName, testKeywordWithinDescribe), + fix: buildFixer(node.callee, nodeName, testKeywordWithinDescribe), }); } }, diff --git a/src/rules/no-disabled-tests.ts b/src/rules/no-disabled-tests.ts index dc5cb6fc5..53f6233e1 100644 --- a/src/rules/no-disabled-tests.ts +++ b/src/rules/no-disabled-tests.ts @@ -39,9 +39,6 @@ export default createRule({ CallExpression(node) { const functionName = getNodeName(node.callee); - // prevent duplicate warnings for it.each()() - if (node.callee.type === 'CallExpression') return; - switch (functionName) { case 'describe.skip': context.report({ messageId: 'skippedTestSuite', node }); @@ -51,10 +48,6 @@ export default createRule({ case 'it.concurrent.skip': case 'test.skip': case 'test.concurrent.skip': - case 'it.skip.each': - case 'test.skip.each': - case 'xit.each': - case 'xtest.each': context.report({ messageId: 'skippedTest', node }); break; } diff --git a/src/rules/no-test-prefixes.ts b/src/rules/no-test-prefixes.ts index 0c61dedfe..1874a06b8 100644 --- a/src/rules/no-test-prefixes.ts +++ b/src/rules/no-test-prefixes.ts @@ -1,4 +1,3 @@ -import { AST_NODE_TYPES } from '@typescript-eslint/experimental-utils'; import { createRule, getNodeName, isDescribe, isTestCase } from './utils'; export default createRule({ @@ -28,17 +27,12 @@ export default createRule({ if (!preferredNodeName) return; - const funcNode = - node.callee.type === AST_NODE_TYPES.TaggedTemplateExpression - ? node.callee.tag - : node.callee; - context.report({ messageId: 'usePreferredName', node: node.callee, data: { preferredNodeName }, fix(fixer) { - return [fixer.replaceText(funcNode, preferredNodeName)]; + return [fixer.replaceText(node.callee, preferredNodeName)]; }, }); }, @@ -49,14 +43,12 @@ export default createRule({ function getPreferredNodeName(nodeName: string) { const firstChar = nodeName.charAt(0); - const suffix = nodeName.endsWith('.each') ? '.each' : ''; - if (firstChar === 'f') { - return `${nodeName.slice(1).replace('.each', '')}.only${suffix}`; + return `${nodeName.slice(1)}.only`; } if (firstChar === 'x') { - return `${nodeName.slice(1).replace('.each', '')}.skip${suffix}`; + return `${nodeName.slice(1)}.skip`; } return null; diff --git a/src/rules/utils.ts b/src/rules/utils.ts index 6e487b4b1..107675d81 100644 --- a/src/rules/utils.ts +++ b/src/rules/utils.ts @@ -580,16 +580,10 @@ export interface JestFunctionCallExpressionWithIdentifierCallee< callee: JestFunctionIdentifier; } -interface JestFunctionCallExpressionWithTaggedTemplateCallee - extends TSESTree.CallExpression { - callee: TSESTree.TaggedTemplateExpression; -} - export type JestFunctionCallExpression< FunctionName extends JestFunctionName = JestFunctionName > = | JestFunctionCallExpressionWithMemberExpressionCallee - | JestFunctionCallExpressionWithTaggedTemplateCallee | JestFunctionCallExpressionWithIdentifierCallee; const joinNames = (a: string | null, b: string | null): string | null => @@ -598,8 +592,7 @@ const joinNames = (a: string | null, b: string | null): string | null => export function getNodeName( node: | JestFunctionMemberExpression - | JestFunctionIdentifier - | TSESTree.TaggedTemplateExpression, + | JestFunctionIdentifier, ): string; export function getNodeName(node: TSESTree.Node): string | null; export function getNodeName(node: TSESTree.Node): string | null { @@ -608,8 +601,6 @@ export function getNodeName(node: TSESTree.Node): string | null { } switch (node.type) { - case AST_NODE_TYPES.TaggedTemplateExpression: - return getNodeName(node.tag); case AST_NODE_TYPES.MemberExpression: return joinNames(getNodeName(node.object), getNodeName(node.property)); case AST_NODE_TYPES.NewExpression: @@ -660,11 +651,6 @@ export const isTestCase = ( ): node is JestFunctionCallExpression => (node.callee.type === AST_NODE_TYPES.Identifier && TestCaseName.hasOwnProperty(node.callee.name)) || - // e.g. it.each``() - (node.callee.type === AST_NODE_TYPES.TaggedTemplateExpression && - node.callee.tag.type === AST_NODE_TYPES.MemberExpression && - isSupportedAccessor(node.callee.tag.property, TestCaseProperty.each)) || - // e.g. it.concurrent.{skip,only} (node.callee.type === AST_NODE_TYPES.MemberExpression && node.callee.property.type === AST_NODE_TYPES.Identifier && TestCaseProperty.hasOwnProperty(node.callee.property.name) && From 5cf1dfb4ca158f04f410a6e63e44f4e761e0f479 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Thu, 12 Nov 2020 14:17:00 +0100 Subject: [PATCH 3/5] chore: keep some tests around --- src/rules/__tests__/consistent-test-it.test.ts | 16 ++++++++++++++++ src/rules/__tests__/no-disabled-tests.test.ts | 1 + src/rules/__tests__/no-done-callback.test.ts | 4 ++++ src/rules/__tests__/no-standalone-expect.test.ts | 4 ++++ src/rules/__tests__/no-test-prefixes.test.ts | 10 ++++++++++ 5 files changed, 35 insertions(+) diff --git a/src/rules/__tests__/consistent-test-it.test.ts b/src/rules/__tests__/consistent-test-it.test.ts index 2c96ea310..150315d81 100644 --- a/src/rules/__tests__/consistent-test-it.test.ts +++ b/src/rules/__tests__/consistent-test-it.test.ts @@ -32,6 +32,14 @@ ruleTester.run('consistent-test-it with fn=test', rule, { code: 'xtest("foo")', options: [{ fn: TestCaseName.test }], }, + { + code: 'test.each([])("foo")', + options: [{ fn: TestCaseName.test }], + }, + { + code: 'test.each``("foo")', + options: [{ fn: TestCaseName.test }], + }, { code: 'describe("suite", () => { test("foo") })', options: [{ fn: TestCaseName.test }], @@ -165,6 +173,14 @@ ruleTester.run('consistent-test-it with fn=it', rule, { code: 'it.concurrent("foo")', options: [{ fn: TestCaseName.it }], }, + { + code: 'it.each([])("foo")', + options: [{ fn: TestCaseName.it }], + }, + { + code: 'it.each``("foo")', + options: [{ fn: TestCaseName.it }], + }, { code: 'describe("suite", () => { it("foo") })', options: [{ fn: TestCaseName.it }], diff --git a/src/rules/__tests__/no-disabled-tests.test.ts b/src/rules/__tests__/no-disabled-tests.test.ts index 3f317c0be..91bc16de2 100644 --- a/src/rules/__tests__/no-disabled-tests.test.ts +++ b/src/rules/__tests__/no-disabled-tests.test.ts @@ -16,6 +16,7 @@ ruleTester.run('no-disabled-tests', rule, { 'it("foo", function () {})', 'describe.only("foo", function () {})', 'it.only("foo", function () {})', + 'it.each("foo", () => {})', 'it.concurrent("foo", function () {})', 'test("foo", function () {})', 'test.only("foo", function () {})', diff --git a/src/rules/__tests__/no-done-callback.test.ts b/src/rules/__tests__/no-done-callback.test.ts index f4fc63903..7c6cd6f6e 100644 --- a/src/rules/__tests__/no-done-callback.test.ts +++ b/src/rules/__tests__/no-done-callback.test.ts @@ -15,6 +15,10 @@ ruleTester.run('no-done-callback', rule, { 'test("something", () => {})', 'test("something", async () => {})', 'test("something", function() {})', + 'test.each``("something", ({ a, b }) => {})', + 'test.each()("something", ({ a, b }) => {})', + 'it.each()("something", ({ a, b }) => {})', + 'it.each``("something", ({ a, b }) => {})', 'test("something", async function () {})', 'test("something", someArg)', 'beforeEach(() => {})', diff --git a/src/rules/__tests__/no-standalone-expect.test.ts b/src/rules/__tests__/no-standalone-expect.test.ts index 7b4944545..7b60f524c 100644 --- a/src/rules/__tests__/no-standalone-expect.test.ts +++ b/src/rules/__tests__/no-standalone-expect.test.ts @@ -57,6 +57,10 @@ ruleTester.run('no-standalone-expect', rule, { }, ], invalid: [ + { + code: "(() => {})('testing', () => expect(true))", + errors: [{ endColumn: 41, column: 29, messageId: 'unexpectedExpect' }], + }, { code: ` describe('scenario', () => { diff --git a/src/rules/__tests__/no-test-prefixes.test.ts b/src/rules/__tests__/no-test-prefixes.test.ts index 330ad0aaa..1ca53fc1f 100644 --- a/src/rules/__tests__/no-test-prefixes.test.ts +++ b/src/rules/__tests__/no-test-prefixes.test.ts @@ -12,8 +12,18 @@ ruleTester.run('no-test-prefixes', rule, { 'test.concurrent("foo", function () {})', 'describe.only("foo", function () {})', 'it.only("foo", function () {})', + 'it.each()("foo", function () {})', + { + code: 'it.each``("foo", function () {})', + parserOptions: { ecmaVersion: 6 }, + }, 'it.concurrent.only("foo", function () {})', 'test.only("foo", function () {})', + 'test.each()("foo", function () {})', + { + code: 'test.each``("foo", function () {})', + parserOptions: { ecmaVersion: 6 }, + }, 'test.concurrent.only("foo", function () {})', 'describe.skip("foo", function () {})', 'it.skip("foo", function () {})', From ac75bfef95564a9044df7926ddd73d416ac37169 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Thu, 12 Nov 2020 14:18:40 +0100 Subject: [PATCH 4/5] chore: add regression test --- src/rules/__tests__/no-done-callback.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rules/__tests__/no-done-callback.test.ts b/src/rules/__tests__/no-done-callback.test.ts index 7c6cd6f6e..6b364b24d 100644 --- a/src/rules/__tests__/no-done-callback.test.ts +++ b/src/rules/__tests__/no-done-callback.test.ts @@ -18,6 +18,7 @@ ruleTester.run('no-done-callback', rule, { 'test.each``("something", ({ a, b }) => {})', 'test.each()("something", ({ a, b }) => {})', 'it.each()("something", ({ a, b }) => {})', + 'it.each([])("something", (a, b) => {})', 'it.each``("something", ({ a, b }) => {})', 'test("something", async function () {})', 'test("something", someArg)', From 191f7681f2b9ca4b5999699a37156e06eeeb4e6a Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Thu, 12 Nov 2020 14:27:38 +0100 Subject: [PATCH 5/5] chore: keep more tests --- .../__tests__/consistent-test-it.test.ts | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/rules/__tests__/consistent-test-it.test.ts b/src/rules/__tests__/consistent-test-it.test.ts index 150315d81..029d7c492 100644 --- a/src/rules/__tests__/consistent-test-it.test.ts +++ b/src/rules/__tests__/consistent-test-it.test.ts @@ -130,6 +130,20 @@ ruleTester.run('consistent-test-it with fn=test', rule, { }, ], }, + { + code: 'it.each([])("foo")', + output: 'test.each([])("foo")', + options: [{ fn: TestCaseName.test }], + errors: [ + { + messageId: 'consistentMethod', + data: { + testKeyword: TestCaseName.test, + oppositeTestKeyword: TestCaseName.it, + }, + }, + ], + }, { code: 'describe("suite", () => { it("foo") })', output: 'describe("suite", () => { test("foo") })', @@ -257,6 +271,20 @@ ruleTester.run('consistent-test-it with fn=it', rule, { }, ], }, + { + code: 'test.each([])("foo")', + output: 'it.each([])("foo")', + options: [{ fn: TestCaseName.it }], + errors: [ + { + messageId: 'consistentMethod', + data: { + testKeyword: TestCaseName.it, + oppositeTestKeyword: TestCaseName.test, + }, + }, + ], + }, { code: 'describe("suite", () => { test("foo") })', output: 'describe("suite", () => { it("foo") })',