Add code coverage

This commit is contained in:
MartinBraquet
2025-11-14 15:23:56 +01:00
parent 137d15ae71
commit 8bdbd5e4fe
9 changed files with 45 additions and 21 deletions

View File

@@ -32,7 +32,7 @@ jobs:
run: npm run lint
- name: Run Jest tests
run: npm run test tests/jest
run: npm run test:coverage
# - name: Build app
# env:
@@ -52,9 +52,18 @@ jobs:
NEXT_PUBLIC_FIREBASE_API_KEY: ${{ secrets.NEXT_PUBLIC_FIREBASE_API_KEY }}
NEXT_PUBLIC_SUPABASE_KEY: ${{ secrets.NEXT_PUBLIC_SUPABASE_KEY }}
run: |
yarn --cwd=web serve &
npx nyc --reporter=lcov yarn --cwd=web serve &
npx wait-on http://localhost:3000
npx playwright test tests/e2e
SERVER_PID=$(fuser -k 3000/tcp)
echo $SERVER_PID
kill $SERVER_PID
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
files: ./coverage/lcov.info
flags: unit
fail_ci_if_error: true
env:
CI: true

3
.gitignore vendored
View File

@@ -64,7 +64,7 @@ email-preview
*.last-run.json
*lock.hcl
/web/pages/test.tsx
/web/pages/_test.tsx
*.png
*.jpg
@@ -97,3 +97,4 @@ icons/
*.bak
test-results
/.nyc_output/

View File

@@ -1,7 +1,9 @@
[![CI](https://github.com/CompassConnections/Compass/actions/workflows/ci.yml/badge.svg)](https://github.com/CompassConnections/Compass/actions/workflows/ci.yml)
[![CD](https://github.com/CompassConnections/Compass/actions/workflows/cd.yml/badge.svg)](https://github.com/CompassConnections/Compass/actions/workflows/cd.yml)
![Vercel](https://deploy-badge.vercel.app/vercel/compass)
[![CD](https://github.com/CompassConnections/Compass/actions/workflows/cd.yml/badge.svg)](https://github.com/CompassConnections/Compass/actions/workflows/cd.yml)
[![CI](https://github.com/CompassConnections/Compass/actions/workflows/ci.yml/badge.svg)](https://github.com/CompassConnections/Compass/actions/workflows/ci.yml)
[![codecov](https://codecov.io/gh/CompassConnections/Compass/branch/main/graph/badge.svg)](https://codecov.io/gh/CompassConnections/Compass)
# Compass

View File

@@ -76,6 +76,6 @@ describe('getSocialUrl', () => {
it('should handle discord user IDs and default invite', () => {
expect(getSocialUrl('discord', '123456789012345678')).toBe('https://discord.com/users/123456789012345678')
expect(getSocialUrl('discord', 'not-an-id')).toBe({discordLink})
expect(getSocialUrl('discord', 'not-an-id')).toBe(discordLink)
})
})

View File

@@ -0,0 +1,7 @@
import {jsonToMarkdown} from "../src/md";
describe('JSON to Markdown', () => {
it('', () => {
expect(jsonToMarkdown({})).toBe('')
})
})

16
jest.config.js Normal file
View File

@@ -0,0 +1,16 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
testMatch: ['**/*.test.ts'],
testPathIgnorePatterns: [
// '/node_modules/',
// '/dist/',
// '/coverage/',
'/tests/e2e',
// '/lib/',
// 'backend/email/emails/test.ts',
'common/src/socials.test.ts',
// 'backend/api/src',
// 'martin',
],
};

View File

@@ -21,13 +21,13 @@
"sync-android": "./scripts/sync_android.sh",
"migrate": "./scripts/migrate.sh",
"test": "jest",
"test:coverage": "jest --coverage",
"test:watch": "jest --watch",
"test:update": "jest --updateSnapshot",
"playwright": "playwright test",
"playwright:ui": "playwright test --ui",
"playwright:debug": "playwright test --debug",
"playwright:report": "npx playwright show-report tests/reports/playwright-report",
"test:watch": "jest --watch",
"test:coverage": "jest --coverage",
"test:update": "jest --updateSnapshot",
"postinstall": "./scripts/post_install.sh"
},
"dependencies": {

View File

@@ -9,7 +9,7 @@ npx playwright install chromium
export NEXT_PUBLIC_API_URL=localhost:8088
export NEXT_PUBLIC_FIREBASE_ENV=DEV
yarn --cwd=web serve &
npx nyc --reporter=lcov yarn --cwd=web serve &
npx wait-on http://localhost:3000
npx playwright test tests/e2e
SERVER_PID=$(fuser -k 3000/tcp)

View File

@@ -1,11 +0,0 @@
// import '@testing-library/jest-dom';
describe('LoadingSpinner', () => {
it('renders something', () => {
// render(<LoadingSpinner/>);
//
// // Check if the spinner has the correct classes
// const spinner = screen.getByTestId('spinner');
// expect(spinner).toHaveClass('animate-spin');
});
});