-
-
Notifications
You must be signed in to change notification settings - Fork 252
Expand file tree
/
Copy pathProject.test.ts
More file actions
75 lines (64 loc) · 2.25 KB
/
Project.test.ts
File metadata and controls
75 lines (64 loc) · 2.25 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import {ppath, xfs, npath} from '@yarnpkg/fslib';
import process from 'node:process';
import {describe, beforeEach, it, expect} from 'vitest';
import {runCli} from './_runCli';
beforeEach(async () => {
// `process.env` is reset after each tests in setupTests.js.
process.env.COREPACK_HOME = npath.fromPortablePath(await xfs.mktempPromise());
process.env.COREPACK_DEFAULT_TO_LATEST = `0`;
});
describe(`ProjectCommand`, () => {
describe(`InstallSubcommand`, () => {
it(`should install with npm`, async () => {
await xfs.mktempPromise(async cwd => {
await xfs.writeJsonPromise(ppath.join(cwd, `package.json`), {
packageManager: `npm@10.8.2`,
dependencies: {
ms: `2.1.3`,
},
});
await expect(runCli(cwd, [`project`, `install`])).resolves.toMatchObject({
exitCode: 0,
stderr: ``,
});
const dir = await xfs.readdirPromise(cwd);
expect(dir).toContain(`package-lock.json`);
expect(dir).toContain(`node_modules`);
});
});
it(`should install with pnpm`, async () => {
await xfs.mktempPromise(async cwd => {
await xfs.writeJsonPromise(ppath.join(cwd, `package.json`), {
packageManager: `pnpm@9.4.0`,
dependencies: {
ms: `2.1.3`,
},
});
await expect(runCli(cwd, [`project`, `install`])).resolves.toMatchObject({
exitCode: 0,
stderr: ``,
});
const dir = await xfs.readdirPromise(cwd);
expect(dir).toContain(`pnpm-lock.yaml`);
expect(dir).toContain(`node_modules`);
});
});
it(`should install with yarn`, async () => {
await xfs.mktempPromise(async cwd => {
await xfs.writeJsonPromise(ppath.join(cwd, `package.json`), {
packageManager: `yarn@2.1.0`,
dependencies: {
ms: `2.1.3`,
},
});
await expect(runCli(cwd, [`project`, `install`])).resolves.toMatchObject({
exitCode: 0,
stderr: ``,
});
const dir = await xfs.readdirPromise(cwd);
expect(dir).toContain(`yarn.lock`);
expect(dir).toContain(`.pnp.js`);
});
});
});
});