This repo uses pnpm to manage monorepo.
- Run
pnpm install
in the repo root folder to install and link dependencies. - Run
pnpm run build
in the repo root folder to build all packages. You can also do that manually by runningpnpm run build
in folderspackages/react-pages
andpackages/theme-doc
. - Run
pnpm run dev
in the repo root folder to build and watch all packages. You can also do that manually by runningpnpm run dev
in folderspackages/react-pages
andpackages/theme-doc
. It will rebuild automatically whenever you change the package source code. So we preferpnpm run dev
topnpm run build
when changing source code frequently.
cd packages/playground/use-theme-doc/ # or other playgrounds
pnpm run dev
pnpm run build
pnpm run ssr
Notice that the playground import theme-doc from it's src so that we can get hmr when editing theme-doc's source files. This setup should only be used during theme development and it's not for package users.
To use breakpoints and explore code execution, you can use the "Run and Debug" feature from VS Code.
- Add a
debugger
statement where you want to stop the code execution. - If you add
debugger
to the source code of a package, make sure to usepnpm run build
orpnpm run dev
to build the package after modifying the code. - Click the "Run and Debug" icon in the activity bar of VS Code, which opens the Run and Debug view.
- Click the "JavaScript Debug Terminal" button in the Run and Debug view, which opens a terminal in VS Code.
- From that terminal, go to
packages/playground/xxx
, and runpnpm run dev
orpnpm run build
orpnpm run ssr
. - The execution will stop at the
debugger
statement, and you can use the Debug toolbar to continue, step over, and restart the process...
This project uses playwright to run integration tests.
If you are running tests for the first time in this repo, you should run pnpm run install-test-deps
in repo root folder to install test deps.
After having test deps installed, run pnpm run test
to run all tests.
Or run pnpm run test-serve
to run tests in vite serve mode only.
Or run pnpm run test-build
to run tests in vite build mode only.
Or run pnpm run test-ssr
to run tests in ssr mode only.
Run pnpm run test file-name-filter
to filter on file name. For example, pnpm run test hmr
will run tests in packages/playground/use-theme-doc/__tests__/hmr.spec.ts
.
Adding --debug
after any test command will make it run in debug mode. For example, pnpm run test hmr --debug
. With this mode enabled, you can play with browser developer tools, exploring selectors, and stop test with await page.pause()
. Checkout playwright debug doc to learn more.
Checkout more test arguments at playwright doc. Most notable arguments are:
--debug
--max-failures=1
make test stop when it encounter the first error, so that you can tackle one problem at a time.--headed
--workers=1
prevent playwright using multiple thread to run tests in parallel.
Currently all runnable tests are located at packages/playground/use-theme-doc/__tests__/
. You can see them as examples.
Test utils are set up at test-setup/utils/index.ts
. They are playwright test fixtures.