
build
task in Turborepo.
Running Tests
To run tests, simply execute:Terminal
__tests__
folder in each app, however we’ve only written a couple of tests for app
project so far.
Adding Tests
We use Testing Library for our tests. It’s a great library that allows you to test your components in a way that’s close to how a user would interact with them. In the__tests__
folder, create a new file called [page].test.tsx
(where [page]
is the name of the page you want to test). Here’s an example of a test for the home
page:
apps/app/__tests__/home.test.tsx
Adding Vitest to other apps
To add Vitest to another app, you’ll need to install the dependencies:Terminal
@repo/testing
package to the devDependencies
section of the package.json
file:
apps/[app]/package.json
vitest.config.ts
in the root of the app and add the following:
apps/[app]/vitest.config.ts
__tests__
folder in the relevant app and add a test
command to the package.json
file:
apps/[app]/package.json
test
script and run the tests.
Then, just follow the instructions above to write tests.