Skip to content

Commit

Permalink
Add code coverage report (#21)
Browse files Browse the repository at this point in the history
* Add cypress coverage report
* Upload codecov result
* show test report in github actions
  • Loading branch information
bill-moj authored Jan 13, 2025
1 parent e7f2607 commit 57ca40a
Show file tree
Hide file tree
Showing 12 changed files with 12,158 additions and 9,118 deletions.
27 changes: 26 additions & 1 deletion .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,34 @@ jobs:
# generic node integration tests using wiremock - feel free to override with local tests if required
node_integration_tests:
name: node integration tests
uses: ministryofjustice/hmpps-github-actions/.github/workflows/node_integration_tests.yml@v2 # WORKFLOW_VERSION
uses: ministryofjustice/hmpps-github-actions/.github/workflows/node_integration_tests.yml@v2.1 # WORKFLOW_VERSION
needs: [node_build]
secrets: inherit
generate_unit_tests_report:
name: generate unit tests report
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: download test artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
pattern: npm_*_test_artifacts
- name: create reports
shell: bash
run: |
npx junit-to-ctrf artifacts/npm_unit_test_artifacts/jest/junit.xml -o artifacts/npm_unit_test_artifacts/jest/ctrf.json
npx github-actions-ctrf tests artifacts/npm_unit_test_artifacts/jest/ctrf.json
npx github-actions-ctrf failed-folded artifacts/npm_unit_test_artifacts/jest/ctrf.json
npx github-actions-ctrf tests artifacts/npm_integration_test_artifacts/ctrf/ctrf-report.json
npx github-actions-ctrf failed-folded artifacts/npm_integration_test_artifacts/ctrf/ctrf-report.json
- name: Upload coverage results to Codecov
uses: codecov/codecov-action@v5
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
needs:
- node_integration_tests
- node_unit_tests
helm_lint:
strategy:
matrix:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ dist
.vscode
dist/
test_results/
ctrf/
integration_tests/videos/
integration_tests/screenshots/
*/*.iml
Expand Down
20 changes: 20 additions & 0 deletions .nycrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"extends": "@istanbuljs/nyc-config-typescript",
"check-coverage": true,
"inPlace": true,
"compact": false,
"exclude": [
"coverage/**",
"packages/*/test{,s}/**",
"**/*.d.ts",
"test{,s}/**",
"test{,-*}.{js,cjs,mjs,ts,tsx,jsx}",
"**/*.cy.ts",
"**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}",
"**/__tests__/**",
"**/{ava,babel,nyc}.config.{js,cjs,mjs}",
"**/jest.config.{js,cjs,mjs,ts}",
"**/{karma,rollup,webpack}.config.js",
"**/.{eslint,mocha}rc.{js,cjs}"
]
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# hmpps-allocate-key-workers-ui

[![repo standards badge](https://img.shields.io/endpoint?labelColor=231f20&color=005ea5&style=flat&label=MoJ%20Compliant&url=https%3A%2F%2Foperations-engineering-reports-prod.cloud-platform.service.justice.gov.uk%2Fapi%2Fv1%2Fcompliant_public_repositories%2Fendpoint%2Fhmpps-allocate-key-workers-ui&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAABmJLR0QA/wD/AP+gvaeTAAAHJElEQVRYhe2YeYyW1RWHnzuMCzCIglBQlhSV2gICKlHiUhVBEAsxGqmVxCUUIV1i61YxadEoal1SWttUaKJNWrQUsRRc6tLGNlCXWGyoUkCJ4uCCSCOiwlTm6R/nfPjyMeDY8lfjSSZz3/fee87vnnPu75z3g8/kM2mfqMPVH6mf35t6G/ZgcJ/836Gdug4FjgO67UFn70+FDmjcw9xZaiegWX29lLLmE3QV4Glg8x7WbFfHlFIebS/ANj2oDgX+CXwA9AMubmPNvuqX1SnqKGAT0BFoVE9UL1RH7nSCUjYAL6rntBdg2Q3AgcAo4HDgXeBAoC+wrZQyWS3AWcDSUsomtSswEtgXaAGWlVI2q32BI0spj9XpPww4EVic88vaC7iq5Hz1BvVf6v3qe+rb6ji1p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aW8BfyWbPEa1SaiTH1VfSENd85NDxHt1plA71LKRvX4BDaAKFlTgLeALtliDUqPrSV6SQCBlypgFlbmIIrCDcAl6nPAawmYhlLKFuB6IrkXAadUNj6TXlhDcCNEB/Jn4FcE0f4UWEl0NyWNvZxGTs89z6ZnatIIrCdqcCtRJmcCPwCeSN3N1Iu6T4VaFhm9n+riypouBnepLsk9p6p35fzwvDSX5eVQvaDOzjnqzTl+1KC53+XzLINHd65O6lD1DnWbepPBhQ3q2jQyW+2oDkkAtdt5udpb7W+Q/OFGA7ol1zxu1tc8zNHqXercfDfQIOZm9fR815Cpt5PnVqsr1F51wI9QnzU63xZ1o/rdPPmt6enV6sXqHPVqdXOCe1rtrg5W7zNI+m712Ir+cer4POiqfHeJSVe1Raemwnm7xD3mD1E/Z3wIjcsTdlZnqO8bFeNB9c30zgVG2euYa69QJ+9G90lG+99bfdIoo5PU4w362xHePxl1slMab6tV72KUxDvzlAMT8G0ZohXq39VX1bNzzxij9K1Qb9lhdGe931B/kR6/zCwY9YvuytCsMlj+gbr5SemhqkyuzE8xau4MP865JvWNuj0b1YuqDkgvH2GkURfakly01Cg7Cw0+qyXxkjojq9Lw+vT2AUY+DlF/otYq1Ixc35re2V7R8aTRg2KUv7+ou3x/14PsUBn3NG51S0XpG0Z9PcOPKWSS0SKNUo9Rv2Mmt/G5WpPF6pHGra7Jv410OVsdaz217AbkAPX3ubkm240belCuudT4Rp5p/DyC2lf9mfq1iq5eFe8/lu+K0YrVp0uret4nAkwlB6vzjI/1PxrlrTp/oNHbzTJI92T1qAT+BfW49MhMg6JUp7ehY5a6Tl2jjmVvitF9fxo5Yq8CaAfAkzLMnySt6uz/1k6bPx59CpCNxGfoSKA30IPoH7cQXdArwCOllFX/i53P5P9a/gNkKpsCMFRuFAAAAABJRU5ErkJggg==)](https://operations-engineering-reports-prod.cloud-platform.service.justice.gov.uk/public-report/hmpps-allocate-key-workers-ui)
[![codecov](https://codecov.io/github/ministryofjustice/hmpps-allocate-key-workers-ui/graph/badge.svg?token=Y9DDNQZ1J1)](https://codecov.io/github/ministryofjustice/hmpps-allocate-key-workers-ui)
[![Docker Repository on ghcr](https://img.shields.io/badge/ghcr.io-repository-2496ED.svg?logo=docker)](https://ghcr.io/ministryofjustice/hmpps-allocate-key-workers-ui)

Template github repo used for new Typescript based projects.
Expand Down
15 changes: 14 additions & 1 deletion cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { defineConfig } from 'cypress'
import coverageTask from '@cypress/code-coverage/task'
import { GenerateCtrfReport } from 'cypress-ctrf-json-reporter'
import { resetStubs } from './integration_tests/mockApis/wiremock'
import auth from './integration_tests/mockApis/auth'
import tokenVerification from './integration_tests/mockApis/tokenVerification'
Expand All @@ -17,7 +19,8 @@ export default defineConfig({
},
taskTimeout: 60000,
e2e: {
setupNodeEvents(on) {
setupNodeEvents(on, config) {
coverageTask(on, config)
on('task', {
reset: resetStubs,
...auth,
Expand All @@ -26,12 +29,22 @@ export default defineConfig({
...prisonApi,
...componentsApi,
})
// eslint-disable-next-line no-new
new GenerateCtrfReport({
on,
})
return config
},
baseUrl: 'http://localhost:3007',
excludeSpecPattern: ['dist', '**/!(*.cy).ts'],
specPattern: '**/*.cy.{js,jsx,ts,tsx}',
supportFile: 'integration_tests/support/index.ts',
experimentalRunAllSpecs: true,
env: {
codeCoverage: {
url: 'http://localhost:3007/__coverage__',
},
},
retries: {
runMode: 2,
},
Expand Down
2 changes: 1 addition & 1 deletion feature.env
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ HMPPS_AUTH_URL=http://localhost:9091/auth
TOKEN_VERIFICATION_API_URL=http://localhost:9091/verification
TOKEN_VERIFICATION_ENABLED=true
REDIS_ENABLED=false
NODE_ENV=development
NODE_ENV=e2e-test
AUTH_CODE_CLIENT_ID=clientid
AUTH_CODE_CLIENT_SECRET=clientsecret
CLIENT_CREDS_CLIENT_ID=clientid
Expand Down
1 change: 1 addition & 0 deletions integration_tests/support/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import './commands'
import '@testing-library/cypress/add-commands'
import '@cypress/code-coverage/support'
Loading

0 comments on commit 57ca40a

Please sign in to comment.