/
releaseCommand.test.ts
49 lines (40 loc) 路 1.71 KB
/
releaseCommand.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
import fixtures from "fixturez";
import publishPackages from "../publishPackages";
import * as git from "@changesets/git";
import { defaultConfig } from "@changesets/config";
import { silenceLogsInBlock } from "@changesets/test-utils";
import runRelease from "..";
jest.mock("../../../utils/cli-utilities");
jest.mock("@changesets/git");
jest.mock("../publishPackages");
const f = fixtures(__dirname);
// @ts-ignore
git.tag.mockImplementation(() => Promise.resolve(true));
// we want to keep other bolt commands still running so our tests are more e2e
// NOTE: This is pretty terrible. Quite obviously bolt is not going to return these results
// each time, but there is only one test that uses the output of this function ('should add git tags')
// and we know this will be heavily refactored once its moved into the bolt org anyway. So we are happy
// to keep this debt in for now. LB takes full responsibility for this if it becomes flakey.
// @ts-ignore
publishPackages.mockImplementation(() =>
Promise.resolve([
{ name: "pkg-a", newVersion: "1.1.0", published: true },
{ name: "pkg-b", newVersion: "1.0.1", published: true },
])
);
describe("running release", () => {
silenceLogsInBlock();
let cwd: string;
beforeEach(async () => {
cwd = f.copy("simple-project");
});
describe("When there is no changeset commits", () => {
// we make sure we still do this so that a later build can clean up after a previously
// failed one (where the change was pushed back but not released and the next build has no
// changeset commits)
it("should still run publishPackages", async () => {
await runRelease(cwd, {}, defaultConfig);
expect(publishPackages).toHaveBeenCalled();
});
});
});