Testing
Medplum strongly believes in the importance of testing.
We use the following tools for testing:
- Jest as the primary test runner
- React Testing Library for React testing
- @testing-library/dom - DOM testing utilities
- @testing-library/jest-dom - Jest matchers for DOM state
- @testing-library/react - Ties it all together: Jest, React, and DOM
Every pull request is analyzed by Sonarcloud and Coveralls for code coverage and other static analysis.
How to test
To run all tests for all packages, use the build script:
npm t
To run all tests for a single package, use npm t
inside the package folder:
cd packages/app
npm t
To run tests for a single file, pass in the file name:
npm t -- src/App.test.tsx
To run a single test in a single file, pass the file name and the test name:
npm t -- src/App.test.tsx -t 'Click logo'
Any time you run npm t
, you can optionally pass in --coverage
to collect code coverage stats. They will be printed in the terminal:
npm t -- --coverage
npm t -- src/App.test.tsx --coverage
npm t -- src/App.test.tsx -t 'Click logo' --coverage