Respect unicorn/prefer-regexp-test (#15701)

This commit is contained in:
Seong Min Park 2025-06-27 10:20:42 +09:00 committed by GitHub
parent 77cc947dfc
commit 74b51b9589
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 15 deletions

View File

@ -1,4 +1,17 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
exports[`falls back to a loader if we encounter a ESM TS config file in a CommonJs project 1`] = `
"PASS __tests__/a-giraffe.js
✓ giraffe"
`;
exports[`falls back to a loader if we encounter a ESM TS config file in a CommonJs project 2`] = `
"Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: <<REPLACED>>
Ran all test suites."
`;
exports[`on node >=24 invalid JS in jest.config.ts (node with native TS support) 1`] = ` exports[`on node >=24 invalid JS in jest.config.ts (node with native TS support) 1`] = `
"Error: Jest: Failed to parse the TypeScript config file <<REPLACED>> "Error: Jest: Failed to parse the TypeScript config file <<REPLACED>>
@ -54,19 +67,6 @@ Time: <<REPLACED>>
Ran all test suites." Ran all test suites."
`; `;
exports[`works with jest.config.ts with cjs contents 1`] = `
"PASS __tests__/a-giraffe.js
✓ giraffe"
`;
exports[`works with jest.config.ts with cjs contents 2`] = `
"Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: <<REPLACED>>
Ran all test suites."
`;
exports[`works with tsconfig.json 1`] = ` exports[`works with tsconfig.json 1`] = `
"PASS __tests__/a-giraffe.js "PASS __tests__/a-giraffe.js
✓ giraffe" ✓ giraffe"

View File

@ -51,7 +51,7 @@ export default async function readConfigFileAndSetRootDir(
error instanceof SyntaxError && error instanceof SyntaxError &&
// Likely ESM in a file interpreted as CJS, which means it needs to be // Likely ESM in a file interpreted as CJS, which means it needs to be
// compiled. We ignore the error and try to load it with a loader. // compiled. We ignore the error and try to load it with a loader.
error.message.match(/Unexpected token '(export|import)'/) /Unexpected token '(export|import)'/.test(error.message)
) )
) { ) {
throw error; throw error;