Testing Guide
Unit Testing
We use vitest to run unit tests.
-
yarn run test
to run all unit tests -
yarn 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 need -
yarn 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 server -
tests/affine-desktop
e2e for electron client features -
tests/affine-desktop-cloud
e2e for electron cloud features, with electron client and node server -
tests/affine-legacy
e2e for legacy client to create data -
tests/affine-local
e2e for web client -
tests/affine-migration
e2e for migration, just in web environment -
tests/storybook
storybook for component -
run e2e case
-
yarn run e2e
run all e2e cases -
yarn 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.