Skip to content

Commit

Permalink
Change the coverage for jest to be aligned with render tests (#3615)
Browse files Browse the repository at this point in the history
* Change the coverage for jest to be aligned with render tests

* Add default reporter to see regular progress

* Fix problem with coverage

* Fix rename

* Remove default reporter from ci

* Remove unneeded files and configuration

* Fix coverage file location
  • Loading branch information
HarelM authored Jan 27, 2024
1 parent 4ed9cf0 commit ac3cedc
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ jobs:
run: nohup Xvfb &
echo "DISPLAY=:0" >> $GITHUB_ENV
- run: npm ci
- run: npm run jest-ci -- --coverage --coverageReporters json text html-spa --selectProjects unit
- run: npm run test-unit-ci
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
files: ${{ github.workspace }}/coverage/coverage-final.json
files: ${{ github.workspace }}/coverage/unit/codecov.json
verbose: true

integration-tests:
Expand Down
17 changes: 17 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,23 @@ const sharedConfig = {
} as Partial<Config>;

const config: Config = {
coverageProvider: 'v8',
reporters: [
'github-actions',
['jest-monocart-coverage', {
name: 'MapLibre Unit Coverage Report',

reports: [
['codecov']
],

sourceFilter: (sourcePath) => {
return !sourcePath.includes('node_modules/') && sourcePath.search(/src\//) !== -1;
},

outputDir: './coverage/unit'
}]
],
projects: [
{
displayName: 'unit',
Expand Down
16 changes: 13 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
"is-builtin-module": "^3.2.1",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jest-monocart-coverage": "^1.0.2",
"jest-webgl-canvas-mock": "^2.5.3",
"jsdom": "^24.0.0",
"json-stringify-pretty-compact": "^4.0.0",
Expand Down Expand Up @@ -165,11 +166,11 @@
"lint-css": "stylelint src/css/maplibre-gl.css",
"test": "run-p lint lint-css test-render jest",
"jest": "jest",
"jest-ci": "jest --reporters=github-actions --reporters=summary",
"test-build": "jest --selectProjects=build",
"test-integration": "jest --selectProjects=integration",
"test-render": "node --no-warnings --loader ts-node/esm test/integration/render/run_render_tests.ts",
"test-unit": "jest --selectProjects=unit",
"test-unit": "jest --selectProjects=unit --reporters=default",
"test-unit-ci": "jest --coverage --selectProjects unit",
"test-watch-roots": "jest --watch",
"codegen": "run-p --print-label generate-dist-package generate-style-code generate-struct-arrays generate-shaders && npm run generate-typings",
"benchmark": "node --no-warnings --loader ts-node/esm test/bench/run-benchmarks.ts",
Expand Down

0 comments on commit ac3cedc

Please sign in to comment.