Skip to content

test typescript code coverage using jest #9

test typescript code coverage using jest

test typescript code coverage using jest #9

name: code-coverage
on:
push:
branches:
- code-coverage
env:
NODEJS_VERSION: v20.11.1
jobs:
run_tests:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install istanbul-merge
run: yarn add istanbul-merge --dev
- name: Run Configure
run: yarn run configure
- name: Run tests and generate coverage reports
run: |
yarn jest --testPathPattern="packages/cactus-api-client/src/test/typescript/(unit|integration|benchmark)/.*/*.test.ts" --coverage --coverageDirectory=./code-coverage-ts/cactus-api-client || true
# Add similar commands for other packages
- name: Cache coverage data
uses: actions/cache@v2
with:
path: |
./code-coverage-ts
key: ${{ runner.os }}-coverage-${{ hashFiles('**/package-lock.json') }}
merge_and_generate_report:
needs: run_tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Restore coverage data
uses: actions/cache@v2
with:
path: |
./code-coverage-ts
key: ${{ runner.os }}-coverage-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-coverage-
- name: Merge coverage reports
run: npx istanbul-merge --out coverage.json ./code-coverage-ts/*/coverage-final.json
- name: Generate HTML report
run: npx istanbul report --include coverage.json --dir cacti html
- name: Output text report
run: npx istanbul report --include coverage.json --dir cacti text
- name: Upload coverage artifacts
uses: actions/upload-artifact@v2
with:
name: code-coverage
path: ./cacti