Testing Guide
Unit Testing
We use vitest to run unit tests.
yarn run test
to run all unit testsyarn run test:ui
enable UI to run tests- config launch.json in vscode https://vitest.dev/guide/debugging.html#vs-code to run single fi
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Debug Current Test File",
"autoAttachChildProcesses": true,
"skipFiles": ["<node_internals>/", "/node_modules/**"],
"program": "${workspaceRoot}/node_modules/vitest/vitest.mjs",
"args": ["dev", "${relativeFile}"],
"smartStep": true,
"console": "integratedTerminal"
}
]
}
E2E Testing
We use playwright to run e2e tests for the web client. There are steps to run e2e:
- start server to speed up
yarn run dev
to run the web server if needyarn workspace @affine/server dev
to run the node server if need- enter the e2e directory
tests/affine-cloud
e2e for web cloud features, with web client and node servertests/affine-desktop
e2e for electron client featurestests/affine-desktop-cloud
e2e for electron cloud features, with electron client and node servertests/affine-legacy
e2e for legacy client to create datatests/affine-local
e2e for web clienttests/affine-migration
e2e for migration, just in web environmenttests/storybook
storybook for component- run e2e case
yarn run e2e
run all e2e casesyarn run e2e --ui
use ui to run e2e cases- use https://marketplace.visualstudio.com/items?itemName=ms-playwright.playwright to run and debug single case.