Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"better-sqlite3": "^11.7.2",
"clipanion": "patch:clipanion@npm%3A3.2.1#~/.yarn/patches/clipanion-npm-3.2.1-fc9187f56c.patch",
"debug": "^4.1.1",
"esbuild": "^0.24.2",
"esbuild": "^0.25.0",
"eslint": "^8.57.0",
"proxy-from-env": "^1.1.0",
"semver": "^7.6.3",
Expand Down
36 changes: 21 additions & 15 deletions tests/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ it(`should refuse to download a package manager if the hash doesn't match`, asyn

await expect(runCli(cwd, [`yarn`, `--version`])).resolves.toMatchObject({
exitCode: 1,
stderr: /Mismatch hashes/,
stderr: expect.stringContaining(`Mismatch hashes`),
stdout: ``,
});
});
Expand All @@ -35,7 +35,7 @@ it(`should refuse to download a known package manager from a URL`, async () => {
// Package managers known by Corepack cannot be loaded from a URL.
await expect(runCli(cwd, [`yarn@https://registry.npmjs.com/yarn/-/yarn-1.22.21.tgz`, `--version`])).resolves.toMatchObject({
exitCode: 1,
stderr: /Illegal use of URL for known package manager/,
stderr: expect.stringContaining(`Illegal use of URL for known package manager`),
stdout: ``,
});

Expand All @@ -57,7 +57,7 @@ it.fails(`should refuse to download a known package manager from a URL in packag

await expect(runCli(cwd, [`yarn`, `--version`])).resolves.toMatchObject({
exitCode: 1,
stderr: /Illegal use of URL for known package manager/,
stderr: expect.stringContaining(`Illegal use of URL for known package manager`),
stdout: ``,
});

Expand All @@ -82,7 +82,7 @@ it(`should require a version to be specified`, async () => {

await expect(runCli(cwd, [`yarn`, `--version`])).resolves.toMatchObject({
exitCode: 1,
stderr: /expected a semver version/,
stderr: `No version specified for yarn in "packageManager" of package.json\n`,
stdout: ``,
});

Expand All @@ -92,7 +92,7 @@ it(`should require a version to be specified`, async () => {

await expect(runCli(cwd, [`yarn`, `--version`])).resolves.toMatchObject({
exitCode: 1,
stderr: /expected a semver version/,
stderr: expect.stringContaining(`expected a semver version`),
stdout: ``,
});

Expand All @@ -102,7 +102,7 @@ it(`should require a version to be specified`, async () => {

await expect(runCli(cwd, [`yarn`, `--version`])).resolves.toMatchObject({
exitCode: 1,
stderr: /expected a semver version/,
stderr: expect.stringContaining(`expected a semver version`),
stdout: ``,
});
});
Expand Down Expand Up @@ -272,7 +272,7 @@ it(`shouldn't allow using regular Yarn commands on npm-configured projects`, asy

await expect(runCli(cwd, [`yarn`, `--version`])).resolves.toMatchObject({
exitCode: 1,
stderr: /This project is configured to use npm/,
stderr: expect.stringContaining(`This project is configured to use npm`),
});
});
});
Expand Down Expand Up @@ -473,7 +473,7 @@ it(`should support disabling the network accesses from the environment`, async (

await expect(runCli(cwd, [`yarn`, `--version`])).resolves.toMatchObject({
stdout: ``,
stderr: /Network access disabled by the environment/,
stderr: expect.stringContaining(`Network access disabled by the environment`),
exitCode: 1,
});
});
Expand Down Expand Up @@ -845,8 +845,8 @@ it(`should download yarn classic from custom registry`, async () => {
process.env.COREPACK_ENABLE_DOWNLOAD_PROMPT = `1`;
await expect(runCli(cwd, [`yarn`, `--version`])).resolves.toMatchObject({
exitCode: 0,
stdout: /^1\.\d+\.\d+\r?\n$/,
stderr: /^! Corepack is about to download https:\/\/registry\.npmmirror\.com\/yarn\/-\/yarn-1\.\d+\.\d+\.tgz\r?\n$/,
stdout: expect.stringMatching(/^1\.\d+\.\d+\r?\n$/),
stderr: expect.stringMatching(/^! Corepack is about to download https:\/\/registry\.npmmirror\.com\/yarn\/-\/yarn-1\.\d+\.\d+\.tgz\r?\n$/),
});

// Should keep working with cache
Expand Down Expand Up @@ -894,7 +894,7 @@ it(`should download latest pnpm from custom registry`, async () => {
await expect(runCli(cwd, [`pnpm`, `--version`], true)).resolves.toMatchObject({
exitCode: 0,
stdout: `pnpm: Hello from custom registry\n`,
stderr: /^! The local project doesn't define a 'packageManager' field\. Corepack will now add one referencing pnpm@1\.9998\.9999@sha1\./,
stderr: expect.stringContaining(`! The local project doesn't define a 'packageManager' field. Corepack will now add one referencing [email protected]+sha1.`),
});

// Should keep working with cache
Expand Down Expand Up @@ -1021,18 +1021,24 @@ describe(`handle integrity checks`, () => {
});
});
});
it(`should return an error when signature does not match with a tag`, async () => {
it(`should return an error when signature does not match with a range`, async () => {
process.env.TEST_INTEGRITY = `invalid_signature`; // See `_registryServer.mjs`

await xfs.mktempPromise(async cwd => {
await expect(runCli(cwd, [`[email protected]`, `--version`], true)).resolves.toMatchObject({
exitCode: 1,
stderr: /Signature does not match/,
stderr: expect.stringContaining(`Signature does not match`),
stdout: ``,
});
await expect(runCli(cwd, [`yarn@stable`, `--version`], true)).resolves.toMatchObject({
});
});
it(`should return an error when signature does not match with a tag`, async () => {
process.env.TEST_INTEGRITY = `invalid_signature`; // See `_registryServer.mjs`

await xfs.mktempPromise(async cwd => {
await expect(runCli(cwd, [`pnpm@latest`, `--version`], true)).resolves.toMatchObject({
exitCode: 1,
stderr: /Signature does not match/,
stderr: expect.stringContaining(`Signature does not match`),
stdout: ``,
});
});
Expand Down
Loading
Loading