Skip to content

Commit

Permalink
Merge pull request #270 from FlorianWoelki/feat/unit-test-workflow
Browse files Browse the repository at this point in the history
Add unit tests and pnpm install workflow
  • Loading branch information
FlorianWoelki authored Oct 15, 2023
2 parents c9bb31b + bf4e2e4 commit 4d58c3a
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: 'Unit Tests'

on:
push:
branches:
- main
pull_request:

jobs:
cache-and-install:
runs-on: ubuntu-latest

permissions:
contents: read
pull-requests: write

steps:
- uses: actions/checkout@v3

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 16

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup pnpm cache
uses: actions/cache@v3
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install

- name: Run unit tests
run: pnpm test:coverage

- name: Report Coverage
if: always()
uses: davelosert/vitest-coverage-report-action@v2
5 changes: 5 additions & 0 deletions vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ export default defineConfig({
setupFiles: ['./src/test-setup.ts'],
environment: 'happy-dom',
coverage: {
reporter: ['text', 'json-summary', 'json'],
provider: 'istanbul',
lines: 70,
branches: 70,
functions: 70,
statements: 70,
},
},
resolve: {
Expand Down

0 comments on commit 4d58c3a

Please sign in to comment.