Skip to content

Commit

Permalink
feat: Improve testing and coverage reporting
Browse files Browse the repository at this point in the history
This commit does the following:

- Configures Jest to generate coverage reports in the  directory.
- Adds  as a Jest reporter to generate JUnit-formatted test results, improving CI visibility.
- Updates the GitHub Actions workflow to upload coverage reports to Codecov, sourced only from the  directory.
- Adds generated coverage reports and JUnit test results to  to prevent them from being committed to the repository.
  • Loading branch information
cubeddu committed Jul 13, 2023
1 parent 009684c commit 20ad39b
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 1,199 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,12 @@ jobs:

- name: Run package tests
run: pnpm test
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: ./graph-explorer/coverage # path to your coverage reports
fail_ci_if_error: true # fail the workflow if Codecov step fails
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
**/node_modules/
**/coverage/
/packages/graph-explorer/junit.xml
1 change: 1 addition & 0 deletions packages/graph-explorer/.npmrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
auto-install-peers=true
engine-strict=true
public-hoist-pattern[]=*
15 changes: 10 additions & 5 deletions packages/graph-explorer/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,22 @@ const config: Config = {
"node_modules/(?!(swiper|dom7)/)",
"node_modules/(?!(react-dnd-html5-backend)/)"
],
coverageDirectory: '../coverage',
testPathIgnorePatterns: [
'<rootDir>/node_modules/'
],
collectCoverageFrom: [
'**/*.(t|j)s',
],
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/packages/$1/src',
},
coverageReporters: ['text', 'lcov'],
coverageDirectory: '../coverage',
collectCoverage: true, // collect coverage info
collectCoverageFrom: [
"src/**/*.{js,ts}", // specify the files to collect coverage from
],
coverageReporters: ["json", "lcov", "text", "clover"], // lcov is required by Codecov
"reporters": [
"default",
"jest-github-actions-reporter"
],
};

export default config;
2 changes: 2 additions & 0 deletions packages/graph-explorer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@
"husky": "^8.0.0",
"jest": "^28.1.3",
"jest-environment-jsdom": "^29.0.1",
"jest-github-actions-reporter": "^1.0.3",
"jest-junit": "^16.0.0",
"jest-localstorage-mock": "^2.4.26",
"lint-staged": "^13.0.3",
"prettier": "2.1.2",
Expand Down
Loading

0 comments on commit 20ad39b

Please sign in to comment.