Skip to content

Commit 2d6ac86

Browse files
committed
mock it
1 parent 685d24e commit 2d6ac86

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

packages/jest-config/src/__tests__/normalize.test.ts

+18
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import * as path from 'path';
1111
import semver = require('semver');
1212
import type {Config} from '@jest/types';
1313
import {escapeStrForRegex} from 'jest-regex-util';
14+
import {requireOrImportModule} from 'jest-util';
1415
import Defaults from '../Defaults';
1516
import {DEFAULT_JS_PATTERN} from '../constants';
1617
import normalize, {type AllOptions} from '../normalize';
@@ -26,6 +27,23 @@ jest
2627
...realFs,
2728
statSync: () => ({isDirectory: () => true}),
2829
};
30+
})
31+
.mock('jest-util', () => {
32+
const realUtil =
33+
jest.requireActual<typeof import('jest-util')>('jest-util');
34+
35+
return {
36+
...realUtil,
37+
requireOrImportModule: (filePath: string, interop = true) => {
38+
const result = require(filePath);
39+
40+
if (interop) {
41+
return realUtil.interopRequireDefault(result).default;
42+
}
43+
44+
return result;
45+
},
46+
};
2947
});
3048

3149
let root: string;

0 commit comments

Comments
 (0)