Bit can run the component's tests in an isolated component environment.
Executing components tests
In order to test a component, you need to have a tester defined.
Defining a tester for your project
$ bit import bit.envs/testers/mocha --tester the following component environments were installed - email@example.com
You can now go take a look at the
env configuration in your bit.json and see your tester over there.
Curated list of test environments on Bitsrc.io
Adding test/spec files to your components
Bit is not going to guess which files are your spec files, right? You should track your spec files correctly.
Test your component
Once you have a defined tester, you can test your component:
$ bit test foo/bar foo/bar tests passed file: dist/test/bar.test.js total duration - 4ms ✔ bar should do nothing - 1ms
Executing component tests remotely
When staging or exporting components, Bit runs the components' extensions in an isolated component environment. So the
test process for the component will run outside the context of the project. This allows Bit to make sure the component is truly isolated.
After exporting a component to a bitsrc.io managed Scope, bitsrc.io will create an isolated container, where the component will be built and then tested in the remote Scope in an isolated component environment.
When the tests have finished running, their results will be displayed as part of the component's documentation on bitsrc.io.
As the Scope owner or collaborator, you can enter the component page on bitsrc.io, and view the CI results in the
Console Output tab.
Implementing a tester
You can implement your own custom tester. See here for more details.