Skip to content

Commit 5c723bf

Browse files
choldgrafrowanc1
andauthored
📖 Add documentation for running test suite (#2226)
Co-authored-by: Rowan Cockett <[email protected]>
1 parent 2e535c1 commit 5c723bf

File tree

1 file changed

+48
-4
lines changed

1 file changed

+48
-4
lines changed

docs/developer.md

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,8 @@ Below you will see several `npm run x` commands.
263263
These are simply aliases for other commands, defined in the [`package.json` file](https://github.com/jupyter-book/mystmd/blob/main/package.json) under "scripts".
264264
```
265265

266-
## Developer workflow: myst CLI
266+
(developer:mystmd)=
267+
## Local development: `mystmd`
267268

268269
The `mystmd` libraries and command line tools are written in [TypeScript](https://www.typescriptlang.org/), and require [NodeJS and npm](https://nodejs.org) for local development.
269270

@@ -306,7 +307,7 @@ The build process uses unix commands that might not work properly on Windows.
306307
When building on Windows, use either WSL or a unix-like shell (such as Git Bash or MSYS2), and make sure that npm is set to use these by default (`npm config set script-shell path/to/shell.exe`).
307308
```
308309

309-
## Developer workflow: myst-theme
310+
## Local development: myst-theme
310311

311312
The [`myst-theme` README](https://github.com/jupyter-book/myst-theme/) provides a more detailed overview of the components of that package.
312313

@@ -456,15 +457,58 @@ The process for releasing `myst-theme` infrastructure is similar to the release
456457

457458
We use [Turbo](https://turborepo.com/) to manage our testing and build system.
458459

460+
(developer:testing)=
459461
### Testing
460462

461-
Tests help ensure that code operates as intended, and that changes do not break existing code. You can run the test suite using:
463+
We use [vitest](https://vitest.dev/guide/) for all tests in `mystmd`.
464+
465+
#### How to run the test suite
466+
467+
First [install `mystmd` locally](#developer:mystmd).
468+
469+
Then, run the test suite using:
462470

463471
```shell
464472
npm run test
465473
```
466474

467-
If you are working in a particular package, change your working directory to that specific package, and run the tests there. To run in "watch mode" (runs each time a change is saved), use `npm run test:watch`.
475+
If you are working in a particular package, change your working directory to that specific package, and run the tests there.
476+
477+
```shell
478+
cd packages/myst-cli
479+
npm run test
480+
```
481+
482+
To run in "watch mode" (runs each time a change is saved), use:
483+
484+
```shell
485+
npm run test:watch
486+
```
487+
488+
To run a single test by matching its title, first change the working directory to the package where the test exists. For example:
489+
490+
```shell
491+
cd packages/mystmd
492+
```
493+
494+
Then run the `npm test` command like so:
495+
496+
```shell
497+
npm run test -- -t "Basic tex build"
498+
```
499+
500+
For integration test titles, see `packages/mystmd/tests/exports.yml`.
501+
502+
#### Types of tests
503+
504+
There are two types of tests in the `mystmd` repository:
505+
506+
**Unit Tests** - are attached to each sub-package in the `packages/` directory. These use [`vitest`](https://vitest.dev/) for basic functionality within each package. They have files like [`config.spec.ts`](https://github.com/jupyter-book/mystmd/blob/main/packages/myst-cli/src/config.spec.ts).
507+
508+
**Integration Tests** - Test the entire `mystmd` build workflow. Here's how it works:
509+
510+
- `packages/mystmd/tests/endToEnd.spec.ts` runs a build from end to end, similar to the `vitest` tests above.
511+
- `packages/mystmd/tests/exports.yml` contains several integration tests - each one points to a build configuration (a folder in `packages/mystmd/tests/`) and compares expected to generated outputs.
468512

469513
### Linting
470514

0 commit comments

Comments
 (0)