-
-
Notifications
You must be signed in to change notification settings - Fork 198
/
Copy pathProject.test.ts
81 lines (70 loc) · 2.71 KB
/
Project.test.ts
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
76
77
78
79
80
81
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`), {
license: `MIT`,
dependencies: {
ms: `2.1.3`,
},
});
await expect(runCli(cwd, [`project`, `install`])).resolves.toMatchObject({
exitCode: 0,
stdout: expect.stringMatching(/^(?!.*Error).*$/s),
stderr: expect.stringContaining(`created a lockfile as package-lock.json`),
});
const dir = await xfs.readdirPromise(cwd);
expect(dir).toContain(`package-lock.json`);
expect(xfs.existsSync(ppath.join(cwd, `node_modules/ms/package.json`))).toBe(true);
});
});
it(`should install with pnpm`, async () => {
await xfs.mktempPromise(async cwd => {
await xfs.writeJsonPromise(ppath.join(cwd, `package.json`), {
license: `MIT`,
dependencies: {
ms: `2.1.3`,
},
});
await expect(runCli(cwd, [`project`, `install`])).resolves.toMatchObject({
exitCode: 0,
stdout: expect.stringMatching(/^(?!.*Error).*$/s),
stderr: ``,
});
const dir = await xfs.readdirPromise(cwd);
expect(dir).toContain(`pnpm-lock.yaml`);
expect(xfs.existsSync(ppath.join(cwd, `node_modules/ms/package.json`))).toBe(true);
});
});
it(`should install with yarn`, async () => {
await xfs.mktempPromise(async cwd => {
await xfs.writeJsonPromise(ppath.join(cwd, `package.json`), {
license: `MIT`,
dependencies: {
ms: `2.1.3`,
},
});
await expect(runCli(cwd, [`project`, `install`])).resolves.toMatchObject({
exitCode: 0,
stdout: expect.stringMatching(/^(?!.*Error).*$/s),
stderr: ``,
});
const dir = await xfs.readdirPromise(cwd);
expect(dir).toContain(`yarn.lock`);
expect(xfs.existsSync(ppath.join(cwd, `node_modules/ms/package.json`))).toBe(true);
});
});
});
});