Skip to content

Commit

Permalink
feat: improve test coverage (AppFlowy-IO#5481)
Browse files Browse the repository at this point in the history
  • Loading branch information
qinluhe authored Jun 6, 2024
1 parent d73e388 commit 3b72f90
Show file tree
Hide file tree
Showing 57 changed files with 2,274 additions and 716 deletions.
16 changes: 11 additions & 5 deletions .github/workflows/web_coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- ".github/workflows/web2_ci.yaml"
- "frontend/appflowy_web_app/**"
- "frontend/resources/**"

env:
NODE_VERSION: "18.16.0"
PNPM_VERSION: "8.5.0"
Expand Down Expand Up @@ -52,8 +53,13 @@ jobs:
run: |
pnpm run test:unit
- name: Generate and post coverage summary
working-directory: frontend/appflowy_web_app
run: |
pnpm run merge-coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
with:
token: cf9245e0-e136-4e21-b0ee-35755fa0c493
files: frontend/appflowy_web_app/coverage/jest/lcov.info,frontend/appflowy_web_app/coverage/cypress/lcov.info
flags: appflowy_web_app
name: frontend/appflowy_web_app
fail_ci_if_error: true
verbose: true

5 changes: 3 additions & 2 deletions frontend/appflowy_web_app/.nycrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"all": true,
"extends": "@istanbuljs/nyc-config-typescript",
"extends": "@istanbuljs/nyc-config-babel",
"include": [
"src/**/*.ts",
"src/**/*.tsx"
Expand All @@ -15,7 +15,8 @@
"text",
"html",
"text-summary",
"json"
"json",
"lcov"
],
"temp-dir": "coverage/.nyc_output",
"report-dir": "coverage/cypress"
Expand Down
22 changes: 20 additions & 2 deletions frontend/appflowy_web_app/jest.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const esModules = ['lodash-es', 'nanoid'].join('|');
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
testEnvironment: 'jsdom',
roots: ['<rootDir>'],
modulePaths: [compilerOptions.baseUrl],
moduleNameMapper: {
Expand All @@ -14,10 +14,28 @@ module.exports = {
'^nanoid(/(.*)|$)': 'nanoid$1',
},
'transform': {
'^.+\\.(j|t)sx?$': 'ts-jest',
'(.*)/node_modules/nanoid/.+\\.(j|t)sx?$': 'ts-jest',
},
'transformIgnorePatterns': [`/node_modules/(?!${esModules})`],
testMatch: ['**/*.test.ts'],
testMatch: ['**/*.test.ts', '**/*.test.tsx'],
coverageDirectory: '<rootDir>/coverage/jest',
collectCoverage: true,
coverageProvider: 'v8',
coveragePathIgnorePatterns: [
'/cypress/',
'/coverage/',
'/node_modules/',
'/__tests__/',
'/__mocks__/',
'/__fixtures__/',
'/__helpers__/',
'/__utils__/',
'/__constants__/',
'/__types__/',
'/__mocks__/',
'/__stubs__/',
'/__fixtures__/',
'/application/folder-yjs/',
],
};
7 changes: 5 additions & 2 deletions frontend/appflowy_web_app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
"test:components": "cypress run --component --browser chrome --headless",
"test:unit": "jest --coverage",
"test:cy": "cypress run",
"merge-coverage": "node scripts/merge-coverage.cjs",
"coverage": "pnpm run test:unit && pnpm run test:components && pnpm run merge-coverage"
"coverage": "pnpm run test:unit && pnpm run test:components"
},
"dependencies": {
"@appflowyinc/client-api-wasm": "0.0.3",
Expand Down Expand Up @@ -99,11 +98,15 @@
"yjs": "^13.6.14"
},
"devDependencies": {
"@babel/preset-env": "^7.24.7",
"@babel/preset-react": "^7.24.7",
"@babel/preset-typescript": "^7.24.7",
"@cypress/code-coverage": "^3.12.39",
"@istanbuljs/nyc-config-babel": "^3.0.0",
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@svgr/plugin-svgo": "^8.0.1",
"@tauri-apps/cli": "^1.5.11",
"@testing-library/react": "^16.0.0",
"@types/google-protobuf": "^3.15.12",
"@types/is-hotkey": "^0.1.7",
"@types/jest": "^29.5.3",
Expand Down
Loading

0 comments on commit 3b72f90

Please sign in to comment.