Skip to content

Commit 6bc1d90

Browse files
committed
npm run test:unit passing locally
Signed-off-by: Tiger Kaovilai <[email protected]>
1 parent 5fb3d75 commit 6bc1d90

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

test/jest-setup.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1-
// Using dynamic imports for ESM compatibility
2-
import 'cli-testing-library/extend-expect';
1+
// Using Node.js module interop for ESM/CommonJS compatibility
2+
import { createRequire } from 'module';
3+
4+
// Create a require function scoped to this module
5+
const moduleRequire = createRequire(import.meta.url);
6+
7+
// Use the scoped require to import CommonJS modules
8+
moduleRequire('cli-testing-library/extend-expect');
39
import { configure } from 'cli-testing-library';
410
import { jest } from '@jest/globals';
511

tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
"target": "ES2020",
44
"lib": ["ES6", "ES2020"],
55

6-
"module": "CommonJS",
6+
"module": "NodeNext",
77

88
"resolveJsonModule": true,
9-
"moduleResolution": "Node",
9+
"moduleResolution": "NodeNext",
1010

1111
"allowJs": true,
1212

0 commit comments

Comments
 (0)