-
Notifications
You must be signed in to change notification settings - Fork 0
51 lines (43 loc) · 1.66 KB
/
test.yml
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
name: CI Test
on:
pull_request:
push:
branches:
- main
jobs:
unit-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install packages
run: npm ci
- name: Test
run: npm run build
- uses: ./
id: run-action
with:
files: .github/workflows/test-data/junit.xml
upload-report: false
- name: Verify output
uses: actions/github-script@v7
with:
script: |
const assert = require('assert').strict;
const data = JSON.parse('${{ steps.run-action.outputs.test-results }}');
assert.strictEqual(data.name, 'unit-test', 'project name');
// test summary
assert.strictEqual(data.summary.duration, 2.017, 'summary duration');
assert.strictEqual(data.summary.tests, 2, 'summary total tests');
assert.strictEqual(data.summary.passed, 1, 'summary passed');
assert.strictEqual(data.summary.failed, 1, 'summary failed');
assert.strictEqual(data.summary.skipped, 0, 'summary skipped');
// test suites
assert.strictEqual(data.suites.length, 1, 'test suite count');
assert.strictEqual(data.suites[0].duration, 2.017, 'summary duration');
assert.strictEqual(data.suites[0].tests, 2, 'summary total tests');
assert.strictEqual(data.suites[0].passed, 1, 'summary passed');
assert.strictEqual(data.suites[0].failed, 1, 'summary failed');
assert.strictEqual(data.suites[0].skipped, 0, 'summary skipped');