Skip to content

Commit 56a60c6

Browse files
authored
fix: require.resolve on default test sequencer and test environment (#11482)
1 parent 50d590a commit 56a60c6

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
### Fixes
1414

15+
- `[jest-config]` `require.resolve` on default test sequencer and test environment ([#11482](https://github.com/facebook/jest/pull/11482))
1516
- `[jest-mock]` Fixed `fn` and `spyOn` exports ([#11480](https://github.com/facebook/jest/pull/11480))
1617

1718
## 27.0.2

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

+13
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,19 @@ describe('testEnvironment', () => {
754754
);
755755
});
756756

757+
it('resolves to node environment by default', async () => {
758+
const {options} = await normalize(
759+
{
760+
rootDir: '/root',
761+
},
762+
{} as Config.Argv,
763+
);
764+
765+
expect(options.testEnvironment).toEqual(
766+
require.resolve('jest-environment-node'),
767+
);
768+
});
769+
757770
it('throws on invalid environment names', async () => {
758771
await expect(
759772
normalize(

packages/jest-config/src/normalize.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,9 @@ export default async function normalize(
608608

609609
options.testEnvironment = resolveTestEnvironment({
610610
rootDir: options.rootDir,
611-
testEnvironment: options.testEnvironment || DEFAULT_CONFIG.testEnvironment,
611+
testEnvironment:
612+
options.testEnvironment ||
613+
require.resolve(DEFAULT_CONFIG.testEnvironment),
612614
});
613615

614616
if (!options.roots && options.testPathDirs) {
@@ -1054,7 +1056,8 @@ export default async function normalize(
10541056
}
10551057

10561058
newOptions.testSequencer = resolveSequencer(newOptions.resolver, {
1057-
filePath: options.testSequencer || DEFAULT_CONFIG.testSequencer,
1059+
filePath:
1060+
options.testSequencer || require.resolve(DEFAULT_CONFIG.testSequencer),
10581061
rootDir: options.rootDir,
10591062
});
10601063

0 commit comments

Comments
 (0)