@@ -198,27 +198,29 @@ install the recommended extensions.
198
198
199
199
## Testing
200
200
201
- - ` pnpm test ` - run unit and feature tests with Jest
202
- - ` pnpm test --watch ` - run tests related to changed files in watch mode
203
- - ` pnpm test --watchAll ` - run all tests in watch mode
204
- - ` pnpm --filter <project-name> test ` - run Jest in a specific project
201
+ - ` pnpm test ` - run unit and feature tests with [ Vitest] ( https://vitest.dev/ ) in
202
+ watch mode (or once when on the CI)
203
+ - ` pnpm test run ` - run unit and feature tests once
204
+ - ` pnpm test [run] <filter> ` - run tests matching the given filter
205
+ - ` pnpm test -- --project <lib|app|...> ` - run Vitest on a specific project
206
+ - ` pnpm test:ui ` - run tests inside the
207
+ [ Vitest UI] ( https://vitest.dev/guide/ui.html )
205
208
- ` pnpm cypress ` - open the
206
209
[ Cypress] ( https://docs.cypress.io/guides/overview/why-cypress.html ) end-to-end
207
210
test runner (local dev server must be running in separate terminal)
208
211
- ` pnpm cypress:run ` - run end-to-end tests once (local dev server must be
209
212
running in separate terminal)
210
213
211
- > Note that the workspace's ` test ` script doesn't recursively run the ` test `
212
- > script in every project like (i.e. it is not equivalent to ` pnpm -r test ` ).
213
- > Instead, it runs Jest globally using a
214
- > [ ` projects ` configuration] ( https://jestjs.io/docs/configuration#projects-arraystring--projectconfig )
215
- > located in ` jest.config.json ` . This results in a nicer terminal output when
216
- > running tests on the entire workspace.
214
+ > Vitest is able to run on the entire monorepo thanks to the
215
+ > [ workspace configuration] ( https://vitest.dev/guide/workspace.html ) defined in
216
+ > ` vitest.workspace.ts ` . It then uses each project's Vite configuration to
217
+ > decide how to run the tests.
217
218
218
219
### Feature tests
219
220
220
221
The ` @h5web/app ` package includes feature tests written with
221
- [ React Testing Library] ( https://testing-library.com/docs/react-testing-library/intro ) .
222
+ [ React Testing Library] ( https://testing-library.com/docs/react-testing-library/intro )
223
+ and running in a [ JSDOM environment] ( https://vitest.dev/guide/environment.html ) .
222
224
They are located under ` src/__tests__ ` . Each file covers a particular subtree of
223
225
components of H5Web.
224
226
@@ -237,9 +239,11 @@ would normally; they just don't stick around in the DOM for long.
237
239
This adds a bit of complexity when testing, as React doesn't like when something
238
240
happens after a test has completed. In fact, we have to ensure that every
239
241
component that suspends inside a test ** finishes loading before the end of that
240
- test** . This is where Testing Library's
241
- [ asynchronous methods] ( https://testing-library.com/docs/dom-testing-library/api-async )
242
- come in.
242
+ test** . To do so, you can use Testing Library's asynchronous APIs for
243
+ [ finding elements] ( https://testing-library.com/docs/dom-testing-library/api-async/#findby-queries )
244
+ and [ interacting with them] ( https://testing-library.com/docs/user-event ) , as
245
+ well as Vitest's [ `waitFor``] ( https://vitest.dev/api/vi.html#vi-waitfor-0-34-5 )
246
+ utility.
243
247
244
248
#### Fake timers
245
249
0 commit comments