Skip to content

Commit 48da90d

Browse files
committed
fix(test): Update Jest configuration and .gitignore
- Add .nvmrc to .gitignore to prevent Node version files from being tracked. - Update Jest configuration to allow transformation of additional modules and fix Haste module naming collisions. - Adjust the Jest setup to ensure consistent test behavior by importing necessary libraries correctly. These changes enhance the testing environment and maintain cleaner project files.
1 parent 5381c5e commit 48da90d

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ uncaughtExceptions.log
1111
src/*.json
1212
.idea
1313
test.ts
14-
notes.md
14+
notes.md
15+
.nvmrc

jest.config.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,33 @@ const config: Config = {
99
testTimeout: 100_000,
1010
coverageProvider: 'v8',
1111
moduleDirectories: ['node_modules', 'src'],
12-
preset: 'ts-jest/presets/js-with-ts-esm',
12+
preset: 'ts-jest/presets/default-esm',
1313
setupFilesAfterEnv: ['<rootDir>/test/jest-setup.ts'],
1414
testEnvironment: 'node',
1515
testRegex: ['.*\\.test\\.ts$'],
16-
transformIgnorePatterns: ['node_modules/(?!cli-testing-library)'],
16+
transformIgnorePatterns: [
17+
'node_modules/(?!(cli-testing-library|@clack|cleye)/.*)'
18+
],
1719
transform: {
18-
'^.+\\.(ts|tsx)$': [
20+
'^.+\\.(ts|tsx|js|jsx|mjs)$': [
1921
'ts-jest',
2022
{
2123
diagnostics: false,
22-
useESM: true
24+
useESM: true,
25+
tsconfig: {
26+
// Explicitly tell ts-jest to target modern ESM
27+
module: 'ESNext',
28+
target: 'ES2022'
29+
}
2330
}
2431
]
32+
},
33+
// Fix Haste module naming collision
34+
modulePathIgnorePatterns: [
35+
'<rootDir>/test/e2e/prompt-module/data/'
36+
],
37+
moduleNameMapper: {
38+
'^(\\.{1,2}/.*)\\.js$': '$1'
2539
}
2640
};
2741

test/jest-setup.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import 'cli-testing-library/extend-expect'
2-
import { configure } from 'cli-testing-library'
31
import { jest } from '@jest/globals';
2+
import 'cli-testing-library/extend-expect';
3+
import { configure } from 'cli-testing-library';
44

55
global.jest = jest;
66

77
/**
88
* Adjusted the wait time for waitFor/findByText to 2000ms, because the default 1000ms makes the test results flaky
99
*/
10-
configure({ asyncUtilTimeout: 2000 })
10+
configure({ asyncUtilTimeout: 2000 });

0 commit comments

Comments
 (0)