Fix tests on Node.js v18 (#20109)
This commit is contained in:
1 parent
699026bf74
commit
a9a766f19f
2 files changed
+20
-7
No files matched your search
@@ -112,7 +112,7 @@ jobs:
|
||||
if: ${{ matrix.node == '14' || matrix.node == '16' || matrix.node == '18' }}
|
||||
run: node ./scripts/prepare-test-for-legacy-nodejs.js --node-version ${{ matrix.node }}
|
||||
|
||||
- name: Install Dependencies(mutable)
|
||||
- name: Install Dependencies (mutable)
|
||||
if: ${{ matrix.node == '14' || matrix.node == '16' || matrix.node == '18' }}
|
||||
run: yarn --no-immutable
|
||||
|
||||
|
||||
@@ -97,16 +97,29 @@ const jestLightRunnerVersion =
|
||||
? "0.8.1"
|
||||
: undefined;
|
||||
|
||||
const resolutions = { ...packageJson.resolutions };
|
||||
const devDependencies = { ...packageJson.devDependencies };
|
||||
if (jestVersion) {
|
||||
packageJson.resolutions = {
|
||||
...packageJson.resolutions,
|
||||
...Object.fromEntries(jestDependencies.map((name) => [name, jestVersion])),
|
||||
};
|
||||
Object.assign(
|
||||
resolutions,
|
||||
Object.fromEntries(jestDependencies.map((name) => [name, jestVersion])),
|
||||
);
|
||||
}
|
||||
if (jestLightRunnerVersion) {
|
||||
packageJson.devDependencies["jest-light-runner"] = jestLightRunnerVersion;
|
||||
devDependencies["jest-light-runner"] = jestLightRunnerVersion;
|
||||
|
||||
if (nodeVersion === 18) {
|
||||
Object.assign(resolutions, {
|
||||
// Avoid different versions installed
|
||||
"jest-snapshot": devDependencies.jest,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const content = JSON.stringify(packageJson, undefined, 2);
|
||||
const content = JSON.stringify(
|
||||
{ ...packageJson, resolutions, devDependencies },
|
||||
undefined,
|
||||
2,
|
||||
);
|
||||
|
||||
fs.writeFileSync(packageJsonFile, content);
|
||||
Reference in new issue
Block a user