Skip to content

Commit 2ed54c6

Browse files
Updated all the "npm hooks" tests for v5.0
1 parent cd925b0 commit 2ed54c6

File tree

1 file changed

+26
-20
lines changed

1 file changed

+26
-20
lines changed

test/specs/npm.spec.js

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
const { check, files, mocks, bump } = require("../utils");
44
const { expect } = require("chai");
55

6-
describe.skip("npm version hooks", () => {
6+
describe("npm version hooks", () => {
7+
78
if (process.platform === "win32" && process.env.CI) {
8-
// Spawning NPM fails on Windows due to a bug in NYC (actually in its dependency, spawn-wrap)
9-
// So skip these tests until this bug is fixed: https://github.com/istanbuljs/nyc/issues/760
9+
// Spawning NPM fails on Windows due to a bug in NYC
1010
return;
1111
}
1212

@@ -18,19 +18,20 @@ describe.skip("npm version hooks", () => {
1818
},
1919
});
2020

21-
let cli = bump("--major");
21+
let cli = bump("major");
2222

2323
expect(cli).to.have.stderr("");
2424
expect(cli).to.have.exitCode(0);
2525

2626
expect(cli).to.have.stdout(
27+
`${check} Npm run preversion\n` +
2728
`${check} Updated package.json to 2.0.0\n`
2829
);
2930

30-
let npm = mocks.npm();
31+
let npm = mocks.npmDetails();
3132
expect(npm.length).to.equal(1);
3233

33-
expect(npm[0].cmd).to.equal("npm run preversion");
34+
expect(npm[0].cmd).to.equal("npm run preversion --silent");
3435
expect(npm[0].version).to.equal("1.0.0");
3536
});
3637

@@ -42,19 +43,20 @@ describe.skip("npm version hooks", () => {
4243
},
4344
});
4445

45-
let cli = bump("--major");
46+
let cli = bump("major");
4647

4748
expect(cli).to.have.stderr("");
4849
expect(cli).to.have.exitCode(0);
4950

5051
expect(cli).to.have.stdout(
51-
`${check} Updated package.json to 2.0.0\n`
52+
`${check} Updated package.json to 2.0.0\n` +
53+
`${check} Npm run version\n`
5254
);
5355

54-
let npm = mocks.npm();
56+
let npm = mocks.npmDetails();
5557
expect(npm.length).to.equal(1);
5658

57-
expect(npm[0].cmd).to.equal("npm run version");
59+
expect(npm[0].cmd).to.equal("npm run version --silent");
5860
expect(npm[0].version).to.equal("2.0.0");
5961
});
6062

@@ -66,19 +68,20 @@ describe.skip("npm version hooks", () => {
6668
},
6769
});
6870

69-
let cli = bump("--major");
71+
let cli = bump("major");
7072

7173
expect(cli).to.have.stderr("");
7274
expect(cli).to.have.exitCode(0);
7375

7476
expect(cli).to.have.stdout(
75-
`${check} Updated package.json to 2.0.0\n`
77+
`${check} Updated package.json to 2.0.0\n` +
78+
`${check} Npm run postversion\n`
7679
);
7780

78-
let npm = mocks.npm();
81+
let npm = mocks.npmDetails();
7982
expect(npm.length).to.equal(1);
8083

81-
expect(npm[0].cmd).to.equal("npm run postversion");
84+
expect(npm[0].cmd).to.equal("npm run postversion --silent");
8285
expect(npm[0].version).to.equal("2.0.0");
8386
});
8487

@@ -92,39 +95,42 @@ describe.skip("npm version hooks", () => {
9295
},
9396
});
9497

95-
let cli = bump("--major --commit --tag --push");
98+
let cli = bump("major --commit --tag --push");
9699

97100
expect(cli).to.have.stderr("");
98101
expect(cli).to.have.exitCode(0);
99102

100103
expect(cli).to.have.stdout(
104+
`${check} Npm run preversion\n` +
101105
`${check} Updated package.json to 2.0.0\n` +
106+
`${check} Npm run version\n` +
102107
`${check} Git commit\n` +
103108
`${check} Git tag\n` +
109+
`${check} Npm run postversion\n` +
104110
`${check} Git push\n`
105111
);
106112

107113
let bin = mocks.all();
108114
expect(bin.length).to.equal(7);
109115

110116
// The preversion script runs before anything
111-
expect(bin[0].cmd).to.equal("npm run preversion");
117+
expect(bin[0].cmd).to.equal("npm run preversion --silent");
112118
expect(bin[0].version).to.equal("1.0.0");
113119

114120
// The version script runs after the version has been updated,
115-
expect(bin[1].cmd).to.equal("npm run version");
121+
expect(bin[1].cmd).to.equal("npm run version --silent");
116122
expect(bin[1].version).to.equal("2.0.0");
117123

118124
// Git commit happens after the version has been updated
119-
expect(bin[2].cmd).to.equal('git commit package.json -m "release v2.0.0"');
125+
expect(bin[2].cmd).to.equal('git commit --message "release v2.0.0" package.json');
120126
expect(bin[2].version).to.equal("2.0.0");
121127

122128
// Git tag happens after the version has been updated
123-
expect(bin[3].cmd).to.equal("git tag -a v2.0.0 -m 2.0.0");
129+
expect(bin[3].cmd).to.equal('git tag --annotate --message "release v2.0.0" v2.0.0');
124130
expect(bin[3].version).to.equal("2.0.0");
125131

126132
// The postversion script runs AFTER "git commit" and "git tag", but BEFORE "git push"
127-
expect(bin[4].cmd).to.equal("npm run postversion");
133+
expect(bin[4].cmd).to.equal("npm run postversion --silent");
128134
expect(bin[4].version).to.equal("2.0.0");
129135

130136
// Git push happens after everything else

0 commit comments

Comments
 (0)