forked from nodejs/corepack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUse.test.ts
More file actions
33 lines (27 loc) · 1.1 KB
/
Use.test.ts
File metadata and controls
33 lines (27 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import {ppath, xfs, npath} from '@yarnpkg/fslib';
import assert from 'node:assert';
import process from 'node:process';
import {describe, beforeEach, it} from 'node:test';
import {runCli} from './_runCli';
beforeEach(async () => {
process.env.COREPACK_HOME = npath.fromPortablePath(await xfs.mktempPromise());
process.env.COREPACK_DEFAULT_TO_LATEST = `0`;
});
describe(`UseCommand`, () => {
it(`should set the package manager in the current project`, async () => {
await xfs.mktempPromise(async cwd => {
await xfs.writeJsonPromise(ppath.join(cwd, `package.json`), {
});
assert.deepStrictEqual(await runCli(cwd, [`use`, `yarn@1.22.4`]), {
exitCode: 0,
});
assert.deepStrictEqual(await xfs.readJsonPromise(ppath.join(cwd, `package.json`)), {
packageManager: `yarn@1.22.4+sha256.bc5316aa110b2f564a71a3d6e235be55b98714660870c5b6b2d2d3f12587fb58`,
});
assert.deepStrictEqual(await runCli(cwd, [`yarn`, `--version`]), {
exitCode: 0,
stdout: `1.22.4\n`,
});
});
});
});