GitHub action to merge jest and cypress test coverages.
Details
Basic Usage
on:
pull_request:
push:
branches:
- master
- development
jobs:
coverage:
name: coverage
strategy:
matrix:
node-version: [14.x]
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Cache node modules
uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-${{ env.cache-name }}
${{ runner.os }}-node-
${{ runner.os }}-
- name: Install Dependencies
run: npm ci
- name: Run Tests and display coverage
id: coverage
uses: IIIMPACT/jest-cypress-coverage-action@main
with:
accessToken: ${{secrets.GITHUB_TOKEN}}
fullCoverageDiff: false
prCoverageThreshold: '{"global":{"branches":45,"functions":50,"lines":50,"statements":70}}'
checkForDuplicateMessages: false
prNumber: ${{ github.event.pull_request.number }}-
Run tests and get combined pr test coverage
npm run test:all npm run test:cypress:staging=> e.g. (default output)
.nyc_output/out.json jest-coverage-full/coverage-final.json=> Merge coverage reports
mergewill first Normalise jest coverage reports, removing an enclosingdataproperty on*.d.tsand*.jsfiles and then merging the coveragesnpm run merge -- --report ./jest-coverage-full/coverage-final.json --report ./.nyc_output/out.json -
Test pr coverage against thresholds Get list of files that have changed in the pr
git fetch origin ${branchNameBase}:${branchNameBase} git fetch origin ${branchNameHead}:${branchNameHead}=> Merge coverage reports
mergewill first Normalise jest coverage reports, removing an enclosingdataproperty on*.d.tsand*.jsfiles and then merging the coveragesnpm run merge -- --report ./jest-coverage-full/coverage-final.json --report ./.nyc_output/out.json=> Test coverage report summary against the set thresholds


