build: switch eslint-factory to use __testUtils__ instead of __tests__

Signed-off-by: MT Lewis <mtlewis@users.noreply.github.com>
This commit is contained in:
MT Lewis
2022-10-17 09:37:51 +01:00
parent 24b40140c4
commit 1846952276
2 changed files with 12 additions and 10 deletions
+8 -6
View File
@@ -2,13 +2,15 @@
'@backstage/cli': minor
---
Treat files in `__tests__` and `__mocks__` directories as test files for linting
Treat files in `__testUtils__` and `__mocks__` directories as test files for linting
purposes.
Updates the parts of the eslint configuration generator that specify which files
should be treated as test code to include any files under directories named
`__tests__` or `__mocks__`, to match the default file locations used in Jest.
should be treated as test code to include any files under two additional
directories:
cf.
https://jestjs.io/docs/configuration/#testmatch-arraystring
https://jestjs.io/docs/manual-mocks#mocking-user-modules
- `__mocks__`: this is the directory used by Jest[0] for mock code.
- `__testUtils__`: a suggested location for utility code executed only when
running tests.
[0]: https://jestjs.io/docs/manual-mocks#mocking-user-modules
+4 -4
View File
@@ -96,7 +96,7 @@ function createConfig(dir, extraConfig = {}) {
`!${joinPath(dir, 'src/**')}`,
joinPath(dir, 'src/**/*.test.*'),
joinPath(dir, 'src/**/*.stories.*'),
joinPath(dir, 'src/**/__tests__/**'),
joinPath(dir, 'src/**/__testUtils__/**'),
joinPath(dir, 'src/**/__mocks__/**'),
joinPath(dir, 'src/setupTests.*'),
]
@@ -104,7 +104,7 @@ function createConfig(dir, extraConfig = {}) {
// Legacy config for packages that don't provide a dir
'**/*.test.*',
'**/*.stories.*',
'**/__tests__/**',
'**/__testUtils__/**',
'**/__mocks__/**',
'**/src/setupTests.*',
'**/dev/**',
@@ -141,7 +141,7 @@ function createConfig(dir, extraConfig = {}) {
// Prevent imports of stories or tests
'*.stories*',
'*.test*',
'**/__tests__/**',
'**/__testUtils__/**',
'**/__mocks__/**',
],
},
@@ -168,7 +168,7 @@ function createConfig(dir, extraConfig = {}) {
files: [
'**/*.test.*',
'**/*.stories.*',
'**/__tests__/**',
'**/__testUtils__/**',
'**/__mocks__/**',
'src/setupTests.*',
'!src/**',