Skip to content

Commit 8bdbd5e

Browse files
committed
Add code coverage
1 parent 137d15a commit 8bdbd5e

9 files changed

Lines changed: 45 additions & 21 deletions

File tree

.github/workflows/ci.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
run: npm run lint
3333

3434
- name: Run Jest tests
35-
run: npm run test tests/jest
35+
run: npm run test:coverage
3636

3737
# - name: Build app
3838
# env:
@@ -52,9 +52,18 @@ jobs:
5252
NEXT_PUBLIC_FIREBASE_API_KEY: ${{ secrets.NEXT_PUBLIC_FIREBASE_API_KEY }}
5353
NEXT_PUBLIC_SUPABASE_KEY: ${{ secrets.NEXT_PUBLIC_SUPABASE_KEY }}
5454
run: |
55-
yarn --cwd=web serve &
55+
npx nyc --reporter=lcov yarn --cwd=web serve &
5656
npx wait-on http://localhost:3000
5757
npx playwright test tests/e2e
5858
SERVER_PID=$(fuser -k 3000/tcp)
5959
echo $SERVER_PID
6060
kill $SERVER_PID
61+
62+
- name: Upload coverage to Codecov
63+
uses: codecov/codecov-action@v5
64+
with:
65+
files: ./coverage/lcov.info
66+
flags: unit
67+
fail_ci_if_error: true
68+
env:
69+
CI: true

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ email-preview
6464
*.last-run.json
6565

6666
*lock.hcl
67-
/web/pages/test.tsx
67+
/web/pages/_test.tsx
6868

6969
*.png
7070
*.jpg
@@ -97,3 +97,4 @@ icons/
9797
*.bak
9898

9999
test-results
100+
/.nyc_output/

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11

2-
[![CI](https://github.com/CompassConnections/Compass/actions/workflows/ci.yml/badge.svg)](https://github.com/CompassConnections/Compass/actions/workflows/ci.yml)
3-
[![CD](https://github.com/CompassConnections/Compass/actions/workflows/cd.yml/badge.svg)](https://github.com/CompassConnections/Compass/actions/workflows/cd.yml)
42
![Vercel](https://deploy-badge.vercel.app/vercel/compass)
3+
[![CD](https://github.com/CompassConnections/Compass/actions/workflows/cd.yml/badge.svg)](https://github.com/CompassConnections/Compass/actions/workflows/cd.yml)
4+
[![CI](https://github.com/CompassConnections/Compass/actions/workflows/ci.yml/badge.svg)](https://github.com/CompassConnections/Compass/actions/workflows/ci.yml)
5+
[![codecov](https://codecov.io/gh/CompassConnections/Compass/branch/main/graph/badge.svg)](https://codecov.io/gh/CompassConnections/Compass)
6+
57

68
# Compass
79

common/src/socials.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,6 @@ describe('getSocialUrl', () => {
7676

7777
it('should handle discord user IDs and default invite', () => {
7878
expect(getSocialUrl('discord', '123456789012345678')).toBe('https://discord.com/users/123456789012345678')
79-
expect(getSocialUrl('discord', 'not-an-id')).toBe({discordLink})
79+
expect(getSocialUrl('discord', 'not-an-id')).toBe(discordLink)
8080
})
8181
})
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import {jsonToMarkdown} from "../src/md";
2+
3+
describe('JSON to Markdown', () => {
4+
it('', () => {
5+
expect(jsonToMarkdown({})).toBe('')
6+
})
7+
})

jest.config.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module.exports = {
2+
preset: 'ts-jest',
3+
testEnvironment: 'node',
4+
testMatch: ['**/*.test.ts'],
5+
testPathIgnorePatterns: [
6+
// '/node_modules/',
7+
// '/dist/',
8+
// '/coverage/',
9+
'/tests/e2e',
10+
// '/lib/',
11+
// 'backend/email/emails/test.ts',
12+
'common/src/socials.test.ts',
13+
// 'backend/api/src',
14+
// 'martin',
15+
],
16+
};

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121
"sync-android": "./scripts/sync_android.sh",
2222
"migrate": "./scripts/migrate.sh",
2323
"test": "jest",
24+
"test:coverage": "jest --coverage",
25+
"test:watch": "jest --watch",
26+
"test:update": "jest --updateSnapshot",
2427
"playwright": "playwright test",
2528
"playwright:ui": "playwright test --ui",
2629
"playwright:debug": "playwright test --debug",
2730
"playwright:report": "npx playwright show-report tests/reports/playwright-report",
28-
"test:watch": "jest --watch",
29-
"test:coverage": "jest --coverage",
30-
"test:update": "jest --updateSnapshot",
3131
"postinstall": "./scripts/post_install.sh"
3232
},
3333
"dependencies": {

scripts/e2e.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ npx playwright install chromium
99
export NEXT_PUBLIC_API_URL=localhost:8088
1010
export NEXT_PUBLIC_FIREBASE_ENV=DEV
1111

12-
yarn --cwd=web serve &
12+
npx nyc --reporter=lcov yarn --cwd=web serve &
1313
npx wait-on http://localhost:3000
1414
npx playwright test tests/e2e
1515
SERVER_PID=$(fuser -k 3000/tcp)

tests/jest/some.test.tsx

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)