Skip to content

Commit 1a783f7

Browse files
committed
fix: no-test-id
1 parent c1678a1 commit 1a783f7

2 files changed

Lines changed: 12 additions & 9 deletions

File tree

src/rules/no-test-id-queries.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ const RULE_NAME = 'no-test-id-queries';
77
export type MessageIds = 'noTestIdQueries';
88
type Options = [];
99

10-
const QUERIES_REGEX = `/^(${ALL_QUERIES_VARIANTS.join('|')})TestId$/`;
10+
const QUERY_VARIANTS = [
11+
...ALL_QUERIES_VARIANTS,
12+
...ALL_QUERIES_VARIANTS.map((query) => `${query}Shadow` as const),
13+
];
14+
15+
const QUERIES_REGEX = `/^(${QUERY_VARIANTS.join('|')})TestId$/`;
1116

1217
export default createTestingLibraryRule<Options, MessageIds>({
1318
name: RULE_NAME,

tests/rules/no-test-id-queries.test.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,12 @@ ruleTester.run(rule.name, rule, {
9191
),
9292
// special cases for shadow-dom-testing-library
9393
...[
94-
'ByShadowLabelText',
95-
'ByShadowPlaceholderText',
96-
'ByShadowText',
97-
'ByShadowAltText',
98-
'ByShadowTitle',
99-
'ByShadowDisplayValue',
100-
'ByShadowRole',
101-
'ByShadowTestId',
94+
'getByShadowTestId',
95+
'queryByShadowTestId',
96+
'getAllByShadowTestId',
97+
'queryAllByShadowTestId',
98+
'findByShadowTestId',
99+
'findAllByShadowTestId',
102100
].flatMap((query) =>
103101
createInvalidTestCase('shadow-dom-testing-library', query)
104102
),

0 commit comments

Comments
 (0)