Skip to content

Commit 031f9f6

Browse files
committed
test: add vitest unit tests + CI for the GitHub Action
The action had no unit tests (the old `test` script only built and copied dist into a sibling dir; preserved as `test:gha`). Add vitest and test getParameters() via mocked @actions/core / @actions/github, covering the input contract: app-file XOR app-binary-id, tag parsing, orientation / download-artifacts / report validation, numeric coercion, boolean inputs, device normalisation, default api-url + inferred name, and the github-context metadata (including include-github-context=false). A GitHub Actions workflow runs `pnpm test` on push/PR.
1 parent b65565e commit 031f9f6

4 files changed

Lines changed: 917 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
8+
jobs:
9+
test:
10+
name: Unit tests
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v5
14+
15+
- uses: pnpm/action-setup@v5
16+
with:
17+
run_install: false
18+
19+
- uses: actions/setup-node@v5
20+
with:
21+
node-version: '22'
22+
cache: 'pnpm'
23+
cache-dependency-path: './pnpm-lock.yaml'
24+
25+
- name: Install dependencies
26+
run: pnpm install --frozen-lockfile
27+
28+
- name: Run unit tests
29+
run: pnpm test

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
},
1111
"scripts": {
1212
"build": "ncc build",
13-
"test": "pnpm run build && cp -r dist ../test-gha/gha && cp action.yml ../test-gha/gha"
13+
"test": "vitest run",
14+
"test:gha": "pnpm run build && cp -r dist ../test-gha/gha && cp action.yml ../test-gha/gha"
1415
},
1516
"dependencies": {
1617
"@actions/core": "^2.0.3",
@@ -23,7 +24,8 @@
2324
"@types/node": "^25.4.0",
2425
"@types/node-fetch": "^2.6.13",
2526
"@vercel/ncc": "^0.38.4",
26-
"typescript": "^5.9.3"
27+
"typescript": "^5.9.3",
28+
"vitest": "^4.1.8"
2729
},
2830
"pnpm": {
2931
"overrides": {

0 commit comments

Comments
 (0)