Skip to content

Commit 74b51b9

Browse files
Respect unicorn/prefer-regexp-test (#15701)
1 parent 77cc947 commit 74b51b9

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

e2e/__tests__/__snapshots__/jest.config.ts.test.ts.snap

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
2+
3+
exports[`falls back to a loader if we encounter a ESM TS config file in a CommonJs project 1`] = `
4+
"PASS __tests__/a-giraffe.js
5+
✓ giraffe"
6+
`;
7+
8+
exports[`falls back to a loader if we encounter a ESM TS config file in a CommonJs project 2`] = `
9+
"Test Suites: 1 passed, 1 total
10+
Tests: 1 passed, 1 total
11+
Snapshots: 0 total
12+
Time: <<REPLACED>>
13+
Ran all test suites."
14+
`;
215
316
exports[`on node >=24 invalid JS in jest.config.ts (node with native TS support) 1`] = `
417
"Error: Jest: Failed to parse the TypeScript config file <<REPLACED>>
@@ -54,19 +67,6 @@ Time: <<REPLACED>>
5467
Ran all test suites."
5568
`;
5669
57-
exports[`works with jest.config.ts with cjs contents 1`] = `
58-
"PASS __tests__/a-giraffe.js
59-
✓ giraffe"
60-
`;
61-
62-
exports[`works with jest.config.ts with cjs contents 2`] = `
63-
"Test Suites: 1 passed, 1 total
64-
Tests: 1 passed, 1 total
65-
Snapshots: 0 total
66-
Time: <<REPLACED>>
67-
Ran all test suites."
68-
`;
69-
7070
exports[`works with tsconfig.json 1`] = `
7171
"PASS __tests__/a-giraffe.js
7272
✓ giraffe"

packages/jest-config/src/readConfigFileAndSetRootDir.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export default async function readConfigFileAndSetRootDir(
5151
error instanceof SyntaxError &&
5252
// Likely ESM in a file interpreted as CJS, which means it needs to be
5353
// compiled. We ignore the error and try to load it with a loader.
54-
error.message.match(/Unexpected token '(export|import)'/)
54+
/Unexpected token '(export|import)'/.test(error.message)
5555
)
5656
) {
5757
throw error;

0 commit comments

Comments
 (0)