-
Notifications
You must be signed in to change notification settings - Fork 37
/
cli.test.js
60 lines (54 loc) · 1.7 KB
/
cli.test.js
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
const execa = require("execa");
const { copyDirectory } = require("../helpers/file");
const {
gitInit,
gitAdd,
gitCommit,
gitCommitAll,
gitInitOrigin,
gitPush,
gitTag,
gitGetTags,
} = require("../helpers/git");
const env = {
GH_TOKEN: "test",
NPM_TOKEN: "test",
PATH: process.env.PATH,
};
// Tests.
describe("multi-semantic-release CLI", () => {
test("Initial commit (changes in all packages)", async () => {
// Create Git repo with copy of Yarn workspaces fixture.
const cwd = gitInit();
copyDirectory(`test/fixtures/yarnWorkspaces/`, cwd);
const sha = gitCommitAll(cwd, "feat: Initial release");
const url = gitInitOrigin(cwd);
gitPush(cwd);
// Path to CLI command.
const filepath = `${__dirname}/../../bin/cli.js`;
// Run via command line.
const out = (await execa("node", [filepath], { cwd, env, extendEnv: false })).stdout;
expect(out).toMatch("Started multirelease! Loading 4 packages...");
expect(out).toMatch("Released 4 of 4 packages, semantically!");
});
test("Initial commit (changes in 2 packages, 2 filtered out)", async () => {
// Create Git repo with copy of Yarn workspaces fixture.
const cwd = gitInit();
copyDirectory(`test/fixtures/yarnWorkspaces/`, cwd);
const sha = gitCommitAll(cwd, "feat: Initial release");
const url = gitInitOrigin(cwd);
gitPush(cwd);
// Path to CLI command.
const filepath = `${__dirname}/../../bin/cli.js`;
// Run via command line.
const out = (
await execa("node", [filepath, "--ignore-packages=packages/c/**,packages/d/**"], {
cwd,
env,
extendEnv: false,
})
).stdout;
expect(out).toMatch("Started multirelease! Loading 2 packages...");
expect(out).toMatch("Released 2 of 2 packages, semantically!");
});
});