Skip to content

Commit 37c473a

Browse files
committed
test: tolerate npm config json differences
1 parent 5256530 commit 37c473a

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

src/infra/npm-install-env.test.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ function readNpmConfigList(env: NodeJS.ProcessEnv): Record<string, unknown> {
2929
return JSON.parse(raw) as Record<string, unknown>;
3030
}
3131

32+
function expectUnsetNpmJsonConfig(value: unknown): void {
33+
expect(value == null).toBe(true);
34+
}
35+
3236
describe("npm project install env", () => {
3337
it("uses an absolute POSIX script shell for npm lifecycle scripts", () => {
3438
withMockedPlatform("linux", () => {
@@ -294,7 +298,7 @@ describe("npm project install env", () => {
294298

295299
const npmConfig = readNpmConfigList(env);
296300
expect(npmConfig.before).toBe(FROZEN_NOW.toISOString());
297-
expect(npmConfig["min-release-age"]).toBeNull();
301+
expectUnsetNpmJsonConfig(npmConfig["min-release-age"]);
298302
} finally {
299303
fsSync.rmSync(dir, { recursive: true, force: true });
300304
}
@@ -335,8 +339,8 @@ describe("npm project install env", () => {
335339
expect(env.npm_config_before).toBe("");
336340
expect(env.npm_config_min_release_age).toBe("0");
337341
const npmConfig = readNpmConfigList(env);
338-
expect(typeof npmConfig.before).toBe("string");
339-
expect(npmConfig["min-release-age"]).toBeNull();
342+
expect(npmConfig.before == null || typeof npmConfig.before === "string").toBe(true);
343+
expectUnsetNpmJsonConfig(npmConfig["min-release-age"]);
340344
} finally {
341345
fsSync.rmSync(dir, { recursive: true, force: true });
342346
}

0 commit comments

Comments
 (0)