Skip to content

Commit

Permalink
fix: cypress test
Browse files Browse the repository at this point in the history
  • Loading branch information
qinluhe committed Jun 1, 2024
1 parent 438de3e commit 9d34fa0
Show file tree
Hide file tree
Showing 10 changed files with 2,096 additions and 46 deletions.
10 changes: 1 addition & 9 deletions .github/workflows/web2_ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,7 @@ jobs:
working-directory: frontend/appflowy_web_app
run: |
pnpm run lint
- name: Run tests
working-directory: frontend/appflowy_web_app
run: |
pnpm run test:unit --coverage --coverageReporters json-summary
- name: Jest Coverage Comment
uses: MishaKav/jest-coverage-comment@main
with:
coverage-summary-path: frontend/appflowy_web_app/coverage/coverage-summary.json

- name: build and analyze
working-directory: frontend/appflowy_web_app
run: |
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/web_cypress_ci.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Cypress Tests
name: Web Tests

on:
pull_request:
Expand Down Expand Up @@ -45,4 +45,9 @@ jobs:
component: true
build: pnpm run build
start: pnpm run start
browser: chrome
browser: chrome

- name: Jest run
working-directory: frontend/appflowy_web_app
run: |
pnpm run test:unit
7 changes: 7 additions & 0 deletions frontend/appflowy_web_app/.nycrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "@istanbuljs/nyc-config-babel",
"all": true,
"reporter": ["html", "text", "text-summary", "json"],
"report-dir": "./coverage",
"temp-dir": "./coverage/.nyc_output"
}
6 changes: 6 additions & 0 deletions frontend/appflowy_web_app/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import { defineConfig } from 'cypress';
import registerCodeCoverageTasks from '@cypress/code-coverage/task';

export default defineConfig({
component: {
devServer: {
framework: 'react',
bundler: 'vite',
},
setupNodeEvents(on, config) {
registerCodeCoverageTasks(on, config);
return config;
},
supportFile: 'cypress/support/component.ts',
},
retries: {
// Configure retry attempts for `cypress run`
Expand Down
1 change: 0 additions & 1 deletion frontend/appflowy_web_app/cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
//

import { YDoc } from '@/application/collab.type';
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
Expand Down
1 change: 1 addition & 0 deletions frontend/appflowy_web_app/cypress/support/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// ***********************************************************

// Import commands.js using ES2015 syntax:
import '@cypress/code-coverage/support';
import './commands';
import './document';
// Alternatively you can use CommonJS syntax:
Expand Down
3 changes: 2 additions & 1 deletion frontend/appflowy_web_app/jest.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ module.exports = {
},
'transformIgnorePatterns': [`/node_modules/(?!${esModules})`],
testMatch: ['**/*.test.ts'],
coverageDirectory: '<rootDir>/coverage',
coverageDirectory: '<rootDir>/coverage/jest',
collectCoverage: true,
};
9 changes: 8 additions & 1 deletion frontend/appflowy_web_app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
"cypress:open": "cypress open",
"test": "pnpm run test:unit && pnpm run test:components",
"test:components": "cypress run --component --browser chrome --headless",
"test:unit": "jest"
"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"
},
"dependencies": {
"@appflowyinc/client-api-wasm": "0.0.3",
Expand Down Expand Up @@ -96,6 +99,8 @@
"yjs": "^13.6.14"
},
"devDependencies": {
"@cypress/code-coverage": "^3.12.39",
"@istanbuljs/nyc-config-babel": "^3.0.0",
"@svgr/plugin-svgo": "^8.0.1",
"@tauri-apps/cli": "^1.5.11",
"@types/google-protobuf": "^3.15.12",
Expand Down Expand Up @@ -133,7 +138,9 @@
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.6",
"istanbul-lib-coverage": "^3.2.2",
"jest-environment-jsdom": "^29.6.2",
"nyc": "^15.1.0",
"postcss": "^8.4.21",
"prettier": "2.8.4",
"prettier-plugin-tailwindcss": "^0.2.2",
Expand Down
Loading

0 comments on commit 9d34fa0

Please sign in to comment.