Skip to content

Commit ce26621

Browse files
authoredMar 10, 2021
fix(no-identical-titles): support nested describes (#790)
1 parent e5561d6 commit ce26621

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed
 

‎src/rules/__tests__/no-identical-title.test.ts

+9
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,15 @@ ruleTester.run('no-identical-title', rule, {
125125
${'a'}
126126
\`("$description", () => {})
127127
`,
128+
dedent`
129+
describe("top level", () => {
130+
describe.each\`\`("nested each", () => {
131+
describe.each\`\`("nested nested each", () => {})
132+
})
133+
134+
describe("nested", () => {})
135+
})
136+
`,
128137
],
129138
invalid: [
130139
{

‎src/rules/no-identical-title.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,14 @@ export default createRule({
4242
CallExpression(node) {
4343
const currentLayer = contexts[contexts.length - 1];
4444

45+
if (isDescribe(node)) {
46+
contexts.push(newDescribeContext());
47+
}
48+
4549
if (node.callee.type === AST_NODE_TYPES.TaggedTemplateExpression) {
4650
return;
4751
}
4852

49-
if (isDescribe(node)) {
50-
contexts.push(newDescribeContext());
51-
}
5253
const [argument] = node.arguments;
5354

5455
if (!argument || !isStringNode(argument)) {

0 commit comments

Comments
 (0)
Please sign in to comment.