Skip to content

Commit f6f6d84

Browse files
ronamiSimenB
authored andcommitted
fix(jest/no-identical-title): don't show an error for different template literals (#239)
1 parent 4f8ef6d commit f6f6d84

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

rules/__tests__/no-identical-title.test.js

+15
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,21 @@ ruleTester.run('no-identical-title', rule, {
9494
es6: true,
9595
},
9696
},
97+
{
98+
code: ['it(`it1`, () => {});', 'it(`it2`, () => {});'].join('\n'),
99+
env: {
100+
es6: true,
101+
},
102+
},
103+
{
104+
code: [
105+
'describe(`describe1`, () => {});',
106+
'describe(`describe2`, () => {});',
107+
].join('\n'),
108+
env: {
109+
es6: true,
110+
},
111+
},
97112
],
98113

99114
invalid: [

rules/no-identical-title.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ const isFirstArgValid = arg => {
5050
return true;
5151
};
5252

53+
const getArgValue = arg => {
54+
if (arg.type === 'TemplateLiteral') {
55+
return arg.quasis[0].value.raw;
56+
}
57+
58+
return arg.value;
59+
};
60+
5361
module.exports = {
5462
meta: {
5563
docs: {
@@ -68,7 +76,7 @@ module.exports = {
6876
if (!isFirstArgValid(firstArgument)) {
6977
return;
7078
}
71-
const title = node.arguments[0].value;
79+
const title = getArgValue(firstArgument);
7280
handleTestCaseTitles(context, currentLayer.testTitles, node, title);
7381
handleDescribeBlockTitles(
7482
context,

0 commit comments

Comments
 (0)