Skip to content

Commit ba37328

Browse files
authored
Fixes tests (#137)
1 parent 4254f3d commit ba37328

File tree

4 files changed

+19
-21
lines changed

4 files changed

+19
-21
lines changed

test/fail.test.js

+12-14
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,28 @@ jest.afterEach(() => {
1212

1313
jest.test('action has empty error', () => {
1414
process.env[workflowsPath] = 'test/stub/empty';
15+
let result;
1516

1617
try {
17-
cp.execSync(`node ${ip}`, { env: process.env }).toString();
18-
19-
jest.expect(true).toBe(false);
18+
throw cp.execSync(`node ${ip}`, { env: process.env }).toString();
2019
} catch (error) {
21-
const result = error.stdout.toString();
22-
23-
jest.expect(result).toContain('Cannot read properties of null (reading \'jobs\')');
24-
jest.expect(result).not.toContain('No issues were found.');
20+
result = (error.stdout || error).toString();
2521
}
22+
23+
jest.expect(result).toContain('Cannot read properties of null (reading \'jobs\')');
24+
jest.expect(result).not.toContain('No issues were found.');
2625
});
2726

2827
jest.test('action has unpinned error', () => {
2928
process.env[workflowsPath] = 'test/stub/unpinned';
29+
let result;
3030

3131
try {
32-
cp.execSync(`node ${ip}`, { env: process.env }).toString();
33-
34-
jest.expect(true).toBe(false);
32+
throw cp.execSync(`node ${ip}`, { env: process.env }).toString();
3533
} catch (error) {
36-
const result = error.stdout.toString();
37-
38-
jest.expect(result).toContain('actions/checkout@v1 is not pinned to a full length commit SHA.');
39-
jest.expect(result).not.toContain('No issues were found.');
34+
result = (error.stdout || error).toString();
4035
}
36+
37+
jest.expect(result).toContain('actions/checkout@v1 is not pinned to a full length commit SHA.');
38+
jest.expect(result).not.toContain('No issues were found.');
4139
});

test/pass.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ jest.test('actions pass', () => {
2121
let result;
2222

2323
try {
24-
result = execSync(`node ${ip}`, { env: process.env }).toString();
24+
throw execSync(`node ${ip}`, { env: process.env }).toString();
2525
} catch (error) {
26-
throw Error(error.stdout.toString());
26+
result = (error.stdout || error).toString();
2727
}
2828

2929
jest.expect(result).not.toContain('::warning::');

test/stub/unpinned/file.yaml

-5
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,3 @@ jobs:
66
steps:
77
- uses: docker://rhysd/actionlint:latest
88
- uses: docker://rhysd/actionlint:1.6.22
9-
mixedstub:
10-
steps:
11-
- uses: actions/checkout@v1
12-
- uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
13-

test/stub/unpinned/file2.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
jobs:
2+
mixedstub:
3+
steps:
4+
- uses: actions/checkout@v1
5+
- uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f

0 commit comments

Comments
 (0)