Skip to content

Commit 91ea527

Browse files
chore(test): fix some custom registry tests (#649)
Co-authored-by: Thomas Scholtes <geigerzaehler@axiom.fm>
1 parent c388c64 commit 91ea527

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

tests/main.test.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,54 +1039,56 @@ describe(`handle integrity checks`, () => {
10391039
});
10401040
it(`should return an error when hash does not match without a tag`, async () => {
10411041
process.env.TEST_INTEGRITY = `invalid_integrity`; // See `_registryServer.mjs`
1042+
process.env.COREPACK_DEFAULT_TO_LATEST = `1`; // Necessary as the version defined in `config.json` does not exist on the custom registry.
10421043

10431044
await xfs.mktempPromise(async cwd => {
10441045
await expect(runCli(cwd, [`pnpm`, `--version`], true)).resolves.toMatchObject({
10451046
exitCode: 1,
1046-
stderr: /Mismatch hashes. Expected [a-f0-9]{128}, got [a-f0-9]{128}/,
1047+
stderr: expect.stringMatching(/Mismatch hashes. Expected [a-f0-9]{128}, got [a-f0-9]{128}/),
10471048
stdout: ``,
10481049
});
10491050
// A second time to validate the invalid version was not cached.
10501051
await expect(runCli(cwd, [`pnpm`, `--version`], true)).resolves.toMatchObject({
10511052
exitCode: 1,
1052-
stderr: /Mismatch hashes. Expected [a-f0-9]{128}, got [a-f0-9]{128}/,
1053+
stderr: expect.stringMatching(/Mismatch hashes. Expected [a-f0-9]{128}, got [a-f0-9]{128}/),
10531054
stdout: ``,
10541055
});
10551056
await expect(runCli(cwd, [`yarn`, `--version`], true)).resolves.toMatchObject({
10561057
exitCode: 1,
1057-
stderr: /Mismatch hashes. Expected [a-f0-9]{128}, got [a-f0-9]{128}/,
1058+
stderr: expect.stringMatching(/Mismatch hashes. Expected [a-f0-9]{128}, got [a-f0-9]{128}/),
10581059
stdout: ``,
10591060
});
10601061
await expect(runCli(cwd, [`use`, `pnpm`], true)).resolves.toMatchObject({
10611062
exitCode: 1,
1062-
stdout: /Mismatch hashes. Expected [a-f0-9]{128}, got [a-f0-9]{128}/,
1063+
stdout: expect.stringMatching(/Mismatch hashes. Expected [a-f0-9]{128}, got [a-f0-9]{128}/),
10631064
stderr: ``,
10641065
});
10651066
});
10661067
});
10671068
it(`should return an error when signature does not match without a tag`, async () => {
10681069
process.env.TEST_INTEGRITY = `invalid_signature`; // See `_registryServer.mjs`
1070+
process.env.COREPACK_DEFAULT_TO_LATEST = `1`; // Necessary as the version defined in `config.json` does not exist on the custom registry.
10691071

10701072
await xfs.mktempPromise(async cwd => {
10711073
await expect(runCli(cwd, [`pnpm`, `--version`], true)).resolves.toMatchObject({
10721074
exitCode: 1,
1073-
stderr: /Signature does not match/,
1075+
stderr: expect.stringContaining(`Signature does not match`),
10741076
stdout: ``,
10751077
});
10761078
// A second time to validate the invalid version was not cached.
10771079
await expect(runCli(cwd, [`pnpm`, `--version`], true)).resolves.toMatchObject({
10781080
exitCode: 1,
1079-
stderr: /Signature does not match/,
1081+
stderr: expect.stringContaining(`Signature does not match`),
10801082
stdout: ``,
10811083
});
10821084
await expect(runCli(cwd, [`yarn`, `--version`], true)).resolves.toMatchObject({
10831085
exitCode: 1,
1084-
stderr: /Signature does not match/,
1086+
stderr: expect.stringContaining(`Signature does not match`),
10851087
stdout: ``,
10861088
});
10871089
await expect(runCli(cwd, [`use`, `pnpm`], true)).resolves.toMatchObject({
10881090
exitCode: 1,
1089-
stdout: /Signature does not match/,
1091+
stdout: expect.stringContaining(`Signature does not match`),
10901092
stderr: ``,
10911093
});
10921094
});
@@ -1097,12 +1099,12 @@ describe(`handle integrity checks`, () => {
10971099
await xfs.mktempPromise(async cwd => {
10981100
await expect(runCli(cwd, [`yarn@1.9998.9999`, `--version`], true)).resolves.toMatchObject({
10991101
exitCode: 1,
1100-
stderr: /Signature does not match/,
1102+
stderr: expect.stringContaining(`Signature does not match`),
11011103
stdout: ``,
11021104
});
11031105
await expect(runCli(cwd, [`use`, `yarn@1.9998.9999`], true)).resolves.toMatchObject({
11041106
exitCode: 1,
1105-
stdout: /Signature does not match/,
1107+
stdout: expect.stringContaining(`Signature does not match`),
11061108
stderr: ``,
11071109
});
11081110
});
@@ -1113,12 +1115,12 @@ describe(`handle integrity checks`, () => {
11131115
await xfs.mktempPromise(async cwd => {
11141116
await expect(runCli(cwd, [`yarn@1.9998.9999`, `--version`], true)).resolves.toMatchObject({
11151117
exitCode: 1,
1116-
stderr: /Mismatch hashes. Expected [a-f0-9]{128}, got [a-f0-9]{128}/,
1118+
stderr: expect.stringMatching(/Mismatch hashes. Expected [a-f0-9]{128}, got [a-f0-9]{128}/),
11171119
stdout: ``,
11181120
});
11191121
await expect(runCli(cwd, [`use`, `yarn@1.9998.9999`], true)).resolves.toMatchObject({
11201122
exitCode: 1,
1121-
stdout: /Mismatch hashes. Expected [a-f0-9]{128}, got [a-f0-9]{128}/,
1123+
stdout: expect.stringMatching(/Mismatch hashes. Expected [a-f0-9]{128}, got [a-f0-9]{128}/),
11221124
stderr: ``,
11231125
});
11241126
});

0 commit comments

Comments
 (0)