-
Notifications
You must be signed in to change notification settings - Fork 147
/
Copy pathindex.ts
143 lines (125 loc) · 2.99 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
export * from './compat';
export * from './file-import';
export * from './types';
const combineQueries = (variants: string[], methods: string[]): string[] => {
const combinedQueries: string[] = [];
variants.forEach((variant) => {
const variantPrefix = variant.replace('By', '');
methods.forEach((method) => {
combinedQueries.push(`${variantPrefix}${method}`);
});
});
return combinedQueries;
};
const getDocsUrl = (ruleName: string): string =>
`https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/${ruleName}.md`;
const LIBRARY_MODULES = [
'@testing-library/dom',
'@testing-library/angular',
'@testing-library/react',
'@testing-library/preact',
'@testing-library/vue',
'@testing-library/svelte',
'@marko/testing-library',
];
const SYNC_QUERIES_VARIANTS = ['getBy', 'getAllBy', 'queryBy', 'queryAllBy'];
const ASYNC_QUERIES_VARIANTS = ['findBy', 'findAllBy'];
const ALL_QUERIES_VARIANTS = [
...SYNC_QUERIES_VARIANTS,
...ASYNC_QUERIES_VARIANTS,
];
const ALL_QUERIES_METHODS = [
'ByLabelText',
'ByPlaceholderText',
'ByText',
'ByAltText',
'ByTitle',
'ByDisplayValue',
'ByRole',
'ByTestId',
'ByA11yState',
];
const SYNC_QUERIES_COMBINATIONS = combineQueries(
SYNC_QUERIES_VARIANTS,
ALL_QUERIES_METHODS
);
const ASYNC_QUERIES_COMBINATIONS = combineQueries(
ASYNC_QUERIES_VARIANTS,
ALL_QUERIES_METHODS
);
const ALL_QUERIES_COMBINATIONS = [
...SYNC_QUERIES_COMBINATIONS,
...ASYNC_QUERIES_COMBINATIONS,
];
const ASYNC_UTILS = ['waitFor', 'waitForElementToBeRemoved'] as const;
const DEBUG_UTILS = [
'debug',
'logTestingPlaygroundURL',
'prettyDOM',
'logRoles',
'logDOM',
'prettyFormat',
] as const;
const EVENTS_SIMULATORS = ['fireEvent', 'userEvent'] as const;
const TESTING_FRAMEWORK_SETUP_HOOKS = ['beforeEach', 'beforeAll'];
const PROPERTIES_RETURNING_NODES = [
'activeElement',
'children',
'childElementCount',
'firstChild',
'firstElementChild',
'fullscreenElement',
'lastChild',
'lastElementChild',
'nextElementSibling',
'nextSibling',
'parentElement',
'parentNode',
'pointerLockElement',
'previousElementSibling',
'previousSibling',
'rootNode',
'scripts',
];
const METHODS_RETURNING_NODES = [
'closest',
'getElementById',
'getElementsByClassName',
'getElementsByName',
'getElementsByTagName',
'getElementsByTagNameNS',
'querySelector',
'querySelectorAll',
];
const ALL_RETURNING_NODES = [
...PROPERTIES_RETURNING_NODES,
...METHODS_RETURNING_NODES,
];
const PRESENCE_MATCHERS = [
'toBeOnTheScreen',
'toBeInTheDocument',
'toBeTruthy',
'toBeDefined',
];
const ABSENCE_MATCHERS = ['toBeNull', 'toBeFalsy'];
export {
combineQueries,
getDocsUrl,
SYNC_QUERIES_VARIANTS,
ASYNC_QUERIES_VARIANTS,
ALL_QUERIES_VARIANTS,
ALL_QUERIES_METHODS,
SYNC_QUERIES_COMBINATIONS,
ASYNC_QUERIES_COMBINATIONS,
ALL_QUERIES_COMBINATIONS,
ASYNC_UTILS,
DEBUG_UTILS,
EVENTS_SIMULATORS,
TESTING_FRAMEWORK_SETUP_HOOKS,
LIBRARY_MODULES,
PROPERTIES_RETURNING_NODES,
METHODS_RETURNING_NODES,
ALL_RETURNING_NODES,
PRESENCE_MATCHERS,
ABSENCE_MATCHERS,
};