-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
814 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import {ppath, xfs, npath} from '@yarnpkg/fslib'; | ||
import assert from 'node:assert'; | ||
import process from 'node:process'; | ||
import {describe, beforeEach, it} from 'node:test'; | ||
|
||
|
@@ -15,15 +16,15 @@ describe(`UseCommand`, () => { | |
await xfs.writeJsonPromise(ppath.join(cwd, `package.json`), { | ||
}); | ||
|
||
await expect(runCli(cwd, [`use`, `[email protected]`])).resolves.toMatchObject({ | ||
assert.deepStrictEqual(await runCli(cwd, [`use`, `[email protected]`]), { | ||
exitCode: 0, | ||
}); | ||
|
||
await expect(xfs.readJsonPromise(ppath.join(cwd, `package.json`))).resolves.toMatchObject({ | ||
assert.deepStrictEqual(await xfs.readJsonPromise(ppath.join(cwd, `package.json`)), { | ||
packageManager: `[email protected]+sha256.bc5316aa110b2f564a71a3d6e235be55b98714660870c5b6b2d2d3f12587fb58`, | ||
}); | ||
|
||
await expect(runCli(cwd, [`yarn`, `--version`])).resolves.toMatchObject({ | ||
assert.deepStrictEqual(await runCli(cwd, [`yarn`, `--version`]), { | ||
exitCode: 0, | ||
stdout: `1.22.4\n`, | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import {Filename, ppath, xfs, npath, PortablePath} from '@yarnpkg/fslib'; | ||
import assert from 'node:assert/strict'; | ||
import process from 'node:process'; | ||
import {beforeEach, it} from 'node:test'; | ||
|
||
|
@@ -549,13 +550,13 @@ it(`should support running package managers with bin array`, async () => { | |
packageManager: `[email protected]`, | ||
}); | ||
|
||
await expect(runCli(cwd, [`yarnpkg`, `--version`])).resolves.toMatchObject({ | ||
assert.deepEqual(await runCli(cwd, [`yarnpkg`, `--version`]), { | ||
stdout: `2.2.2\n`, | ||
stderr: ``, | ||
exitCode: 0, | ||
}); | ||
|
||
await expect(runCli(cwd, [`yarn`, `--version`])).resolves.toMatchObject({ | ||
assert.deepEqual(await runCli(cwd, [`yarn`, `--version`]), { | ||
stdout: `2.2.2\n`, | ||
stderr: ``, | ||
exitCode: 0, | ||
|
@@ -569,11 +570,11 @@ it(`should handle parallel installs`, async () => { | |
packageManager: `[email protected]`, | ||
}); | ||
|
||
await expect(Promise.all([ | ||
assert.deepEqual(await Promise.all([ | ||
runCli(cwd, [`yarn`, `--version`]), | ||
runCli(cwd, [`yarn`, `--version`]), | ||
runCli(cwd, [`yarn`, `--version`]), | ||
])).resolves.toMatchObject([ | ||
]), [ | ||
{ | ||
stdout: `2.2.2\n`, | ||
stderr: ``, | ||
|
@@ -607,7 +608,7 @@ it(`should not override the package manager exit code`, async () => { | |
process.exitCode = 42; | ||
`); | ||
|
||
await expect(runCli(cwd, [`yarn`, `--version`])).resolves.toMatchObject({ | ||
assert.deepEqual(await runCli(cwd, [`yarn`, `--version`]), { | ||
exitCode: 42, | ||
stdout: ``, | ||
stderr: ``, | ||
|
@@ -633,11 +634,12 @@ it(`should not preserve the process.exitCode when a package manager throws`, asy | |
throw new Error('foo'); | ||
`); | ||
|
||
await expect(runCli(cwd, [`yarn`, `--version`])).resolves.toMatchObject({ | ||
const result = await runCli(cwd, [`yarn`, `--version`]); | ||
assert.deepEqual(result, { | ||
exitCode: 1, | ||
stdout: ``, | ||
stderr: expect.stringContaining(`foo`), | ||
}); | ||
assert.match(result.stderr, /foo/); | ||
}); | ||
}); | ||
|
||
|
@@ -659,7 +661,7 @@ it(`should not set the exit code after successfully launching the package manage | |
}); | ||
`); | ||
|
||
await expect(runCli(cwd, [`yarn`, `--version`])).resolves.toMatchObject({ | ||
assert.deepEqual(await runCli(cwd, [`yarn`, `--version`]), { | ||
exitCode: 42, | ||
stdout: ``, | ||
stderr: ``, | ||
|
@@ -686,7 +688,7 @@ it(`should support package managers in ESM format`, async () => { | |
type: `module`, | ||
}); | ||
|
||
await expect(runCli(cwd, [`yarn`, `--version`])).resolves.toMatchObject({ | ||
assert.deepEqual(await runCli(cwd, [`yarn`, `--version`]), { | ||
exitCode: 0, | ||
stdout: `42\n`, | ||
stderr: ``, | ||
|
Oops, something went wrong.