Skip to content

Add test coverage infrastructure and comprehensive unit tests for core components #486

Add test coverage infrastructure and comprehensive unit tests for core components

Add test coverage infrastructure and comprehensive unit tests for core components #486

name: CPS Shared UI Checker
on:
pull_request:
branches:
- "**"
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x, 22.x, 24.x]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: npm
- name: Install dependencies
run: npm ci
- name: Build app
run: npm run build
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: npm
- name: Install dependencies
run: npm ci
- name: Run unit tests with coverage
run: npm run test:coverage
- name: Comment coverage on PR
uses: ArtiomTr/jest-coverage-report-action@v2
if: github.event_name == 'pull_request'
with:
coverage-file: ./coverage/report.json
base-coverage-file: ./coverage/report.json
skip-step: all
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: npm
- name: Install dependencies
run: npm ci
- name: Lint app
run: npm run lint
cypress:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: npm
- name: Run Cypress tests
uses: cypress-io/github-action@v6
with:
install: true
start: npm run start
browser: chrome
wait-on: http://localhost:4200
generate-api-data:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: npm
- name: Install dependencies
run: npm ci
- name: Generate API data and check for changes
id: generate-api
run: |
npm run generate-json-api
if [[ -n "$(git status --porcelain projects/composition/src/assets/api-data/)" ]]; then
echo "API data has changed. Please commit the updated API data.";
git --no-pager diff projects/composition/src/assets/api-data/
exit 1;
else
echo "No changes in API data.";
fi