/
publishPackages.test.ts
52 lines (45 loc) 路 1.28 KB
/
publishPackages.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
import publishPackages from "../publishPackages";
import * as npmUtils from "../npm-utils";
import { getPackages } from "@manypkg/get-packages";
import { silenceLogsInBlock, testdir } from "@changesets/test-utils";
jest.mock("../npm-utils");
jest.mock("ci-info", () => ({
isCI: true,
}));
describe("publishPackages", () => {
silenceLogsInBlock();
afterEach(() => {
jest.clearAllMocks();
});
describe("when isCI", () => {
it("does not call out to npm to see if otp is required", async () => {
const cwd = await testdir({
"package.json": JSON.stringify({
private: true,
workspaces: ["packages/*"],
}),
"packages/pkg-a/package.json": JSON.stringify({
name: "pkg-a",
version: "1.0.0",
}),
});
// @ts-ignore
npmUtils.infoAllow404.mockImplementation(() => ({
published: false,
pkgInfo: {
version: "1.0.0",
},
}));
// @ts-ignore
npmUtils.publish.mockImplementation(() => ({
published: true,
}));
await publishPackages({
packages: (await getPackages(cwd)).packages,
access: "public",
preState: undefined,
});
expect(npmUtils.getTokenIsRequired).not.toHaveBeenCalled();
});
});
});