Skip to content

Commit

Permalink
feat(tests): enhance test coverage reporting with Jest JUnit integrat…
Browse files Browse the repository at this point in the history
…ion (#160)
  • Loading branch information
Robert27 authored Jan 16, 2025
1 parent 00f7cd9 commit e5e4d83
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 80 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: CI - ESLint, Prettier, Jest, and Codecov
on:
push:
branches: [develop, main]
pull_request:
branches: [develop, main]
jobs:
test:
name: Run tests and collect coverage
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Bun
uses: oven-sh/setup-bun@v2

- name: Install dependencies
run: bun install --frozen-lockfile

- name: Run ESLint
run: bunx eslint . --ext .js,.jsx,.ts,.tsx

- name: Run Prettier
run: bunx prettier . --check

- name: Run tests
run: bunx jest --coverage --reporters=jest-junit

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
directory: ${{ github.action_path }}
token: ${{ secrets.CODECOV_TOKEN }}
slug: getsentry/self-hosted

- name: Upload test results to Codecov
if: ${{ !cancelled() }}
uses: codecov/test-results-action@v1
with:
directory: ${{ github.action_path }}
token: ${{ secrets.CODECOV_TOKEN }}
18 changes: 0 additions & 18 deletions .github/workflows/lint.yml

This file was deleted.

18 changes: 0 additions & 18 deletions .github/workflows/prettier.yml

This file was deleted.

29 changes: 0 additions & 29 deletions .github/workflows/tests.yml

This file was deleted.

Binary file modified bun.lockb
Binary file not shown.
10 changes: 10 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
coverage:
status:
project: #add everything under here, more options at https://docs.codecov.com/docs/commit-status
default:
# basic
target: auto #default
threshold: 0%
base: auto
comment:
enabled: true
13 changes: 13 additions & 0 deletions junit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="jest tests" tests="4" failures="0" errors="0" time="0.373">
<testsuite name="getGroupedTimetable" errors="0" failures="0" skipped="0" timestamp="2025-01-16T19:33:31" time="0.281" tests="4">
<testcase classname="getGroupedTimetable should correctly group and sort timetable entries and exams by date" name="getGroupedTimetable should correctly group and sort timetable entries and exams by date" time="0.004">
</testcase>
<testcase classname="generateKey should generate a unique key for a lecture" name="generateKey should generate a unique key for a lecture" time="0.001">
</testcase>
<testcase classname="isValidRoom should return true for valid room strings" name="isValidRoom should return true for valid room strings" time="0">
</testcase>
<testcase classname="isValidRoom should return false for invalid room strings" name="isValidRoom should return false for invalid room strings" time="0.001">
</testcase>
</testsuite>
</testsuites>
30 changes: 15 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@
"husky": "^9.1.7",
"jest": "~29.7.0",
"jest-expo": "~52.0.3",
"jest-junit": "^16.0.0",
"lint-staged": "^15.4.0",
"prettier": "3.4.2",
"prop-types": "^15.8.1",
Expand All @@ -175,19 +176,18 @@
"[email protected]": "patches/[email protected]"
},
"jest": {
"preset": "jest-expo",
"transformIgnorePatterns": [
"node_modules/(?!((jest-)?react-native|@react-native(-community)?)|expo(nent)?|@expo(nent)?/.*|@expo-google-fonts/.*|react-navigation|@react-navigation/.*|@sentry/react-native|native-base|react-native-svg)"
],
"collectCoverage": true,
"collectCoverageFrom": [
"**/*.{ts,tsx,js,jsx}",
"!**/coverage/**",
"!**/node_modules/**",
"!**/babel.config.js",
"!**/expo-env.d.ts",
"!**/.expo/**"
]
}

"preset": "jest-expo",
"transformIgnorePatterns": [
"node_modules/(?!((jest-)?react-native|@react-native(-community)?)|expo(nent)?|@expo(nent)?/.*|@expo-google-fonts/.*|react-navigation|@react-navigation/.*|@sentry/react-native|native-base|react-native-svg)"
],
"collectCoverage": true,
"collectCoverageFrom": [
"**/*.{ts,tsx,js,jsx}",
"!**/coverage/**",
"!**/node_modules/**",
"!**/babel.config.js",
"!**/expo-env.d.ts",
"!**/.expo/**"
]
}
}

0 comments on commit e5e4d83

Please sign in to comment.