Skip to content

Commit 0892e3f

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 0892e3f

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
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: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,28 @@ 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,
2224
useESM: true
2325
}
2426
]
27+
},
28+
// Fix Haste module naming collision
29+
modulePathIgnorePatterns: [
30+
'<rootDir>/test/e2e/prompt-module/data/'
31+
],
32+
moduleNameMapper: {
33+
'^(\\.{1,2}/.*)\\.js$': '$1'
2534
}
2635
};
2736

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)