Use the unified tester CLI, UI and API, to run the different compilers your workspace components use.
Test all modified components:
$bit test
See command synopsis
The output is similar to the following:
testing total of 3 components in workspace 'my-workspace'
testing 2 components with environment my-org.my-scope/envs/my-react-env
PASS my-scope/ui/heading/heading.spec.tsx
PASS my-scope/ui/heading/heading.spec.tsx
Test Suites: 2 passed, 2 total
Test: 2 passed, 2 total
Time: 1.5s
testing 2 components with environment my-org.my-scope/envs/my-react-env
PASS my-scope/ui/heading/heading.spec.tsx
PASS my-scope/ui/heading/heading.spec.tsx
Test Suites: 2 passed, 2 total
Test: 2 passed, 2 total
Time: 1.5s
Run the following to test all components in the workspace, including unmodified:
$bit test --all
Test in watch mode (re-test on component changes):
$bit test --watch
Test a specific component:
$bit test ui/text
Test a group of components using a glob pattern:
$bit test "my-org.my-scope/**"
Run the following to output the test coverage stats:
$bit test --coverage
The output is similar to the following:
----------------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
----------------------|---------|----------|---------|---------|-------------------
All files | 100 | 100 | 100 | 100 |
text.composition.tsx | 100 | 100 | 100 | 100 |
text.tsx | 100 | 100 | 100 | 100 |
----------------------|---------|----------|---------|---------|-------------------
Run the following to write the test results to a file, in a JUnit format:
$bit test --junit results.xml
The output file, results.xml
at the root of the workspace directory, is similar to the following:
<testsuites> <testsuite name="my-org.my-scope/ui/text" timestamp="2023-02-04T17:43:50.741Z" tests="1" failures="0" errors="0" skipped="0"> <testcase classname="text.spec.tsx" name="should render with the correct text" time="0.03"/> </testsuite> </testsuites>
Run the following to test during build:
$bit build
Runt he following to skip tests during build:
$bit build --skip-tests