Skip to content

Commit ca7e942

Browse files
committed
Fix tests running without token
1 parent 4c52f3e commit ca7e942

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

test/GitHubInfo.spec.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
import { assert } from 'chai';
22
import GitHubInfo from '../lib/src/GitHubInfo';
33

4+
const TOKEN = process.env.GREN_GITHUB_TOKEN;
5+
6+
if (!TOKEN) {
7+
console.log(chalk.blue('Token not present, skipping Gren tests.'));
8+
describe = describe.skip;
9+
}
10+
411
describe('GitHubInfo', () => {
512
let githubInfo;
613

@@ -20,7 +27,7 @@ describe('GitHubInfo', () => {
2027
assert.deepEqual(repo, 'github-release-notes', 'Get the repository name from repo\'s folder');
2128
});
2229

23-
if (process.env.GREN_GITHUB_TOKEN) {
30+
if (TOKEN) {
2431
githubInfo.token.then(({ token }) => {
2532
assert.isOk(token);
2633
});
@@ -30,10 +37,9 @@ describe('GitHubInfo', () => {
3037
assert.isOk(options[0].repo);
3138
assert.isOk(options[0].username);
3239

33-
if (process.env.GREN_GITHUB_TOKEN) {
40+
if (TOKEN) {
3441
assert.isOk(options[1].token);
3542
}
3643
});
37-
3844
});
39-
})
45+
});

test/Gren.spec.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,15 @@ if (!TOKEN) {
1212
}
1313

1414
describe('Gren', () => {
15-
const gren = new Gren({
16-
token: TOKEN,
17-
username: 'github-tools',
18-
repo: 'github-release-notes',
19-
quiet: true
15+
let gren;
16+
17+
before(() => {
18+
gren = new Gren({
19+
token: TOKEN,
20+
username: 'github-tools',
21+
repo: 'github-release-notes',
22+
quiet: true
23+
});
2024
});
2125

2226
it('Should throw an error', () => {

0 commit comments

Comments
 (0)