This project uses Vitest for unit testing, following the same patterns as mystmd.
Running Tests¶
Run all tests across packages:
# From repository root
npm run testRun tests in a specific package:
cd packages/<package-name>
npm run testTest File Locations¶
Tests are located in one of two places, depending on the package:
Co-located with source (used by
@myst-theme/common):Place
.spec.tsfiles alongside source files insrc/Example:
packages/common/src/utils.spec.ts
Separate test directory (used by
@myst-theme/jupyter):Create a
test/directory in the package rootExample:
packages/jupyter/test/thebeOptions.spec.ts
Add a test¶
The root npm run test uses turbo to run tests.
It will run tests in one of the repository packages if you define a test script in its package.json.
For example, see the myst-to-react configuration:
package.json
{
"name": "myst-to-react",
"version": "1.0.1",
...
"scripts": {
"test": "vitest run",
...