Skip to Content

Testing Guide

Unit Testing

We use vitest to run unit tests.

  1. yarn run test to run all unit tests

  2. yarn run test:ui enable UI to run tests

  3. 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:

  1. start server to speed up

  2. yarn run dev to run the web server if need

  3. yarn workspace @affine/server dev to run the node server if need

  4. enter the e2e directory

  5. tests/affine-cloud e2e for web cloud features, with web client and node server

  6. tests/affine-desktop e2e for electron client features

  7. tests/affine-desktop-cloud e2e for electron cloud features, with electron client and node server

  8. tests/affine-legacy e2e for legacy client to create data

  9. tests/affine-local e2e for web client

  10. tests/affine-migration e2e for migration, just in web environment

  11. tests/storybook storybook for component

  12. run e2e case

  13. yarn run e2e run all e2e cases

  14. yarn run e2e --ui use ui to run e2e cases

  15. use https://marketplace.visualstudio.com/items?itemName=ms-playwright.playwright  to run and debug single case.

Last updated on