Docs

Docs

  • Try Bit next-gen (beta) ⮕
  • Docs
  • Tutorials
  • Guides
  • Github

›Components

Introduction

  • Quick Start
  • Installation
  • How bit Works?
  • Bit Workspace
  • FAQ

Components

  • Tracking
  • Compiling
  • Testing
  • Versioning
  • Documenting
  • Exporting
  • Removing & Deprecating
  • Installing
  • Importing
  • Viewing

Advanced

  • Dependencies
  • Overrides
  • CI & Deployment
  • Bit Server

bit.dev

  • Functionality
  • Account
  • Authentication

Reference

  • Bit Client Configuration
  • Workspace Configuration
  • CLI Commands
  • Usage Analytics

Extending Bit

  • Extending Bit
  • Using Extensions
  • Developing Extensions
  • Build a compiler
  • Build a tester
Edit

Testing

Bit can run tests for components which have a test task defined.

Basics of testing Components

A component can contain test files. Bit executes them using test runners. Bit tests components using specialised components called Testers. A Tester is a component that takes another component's test files and executes them using test runners.

Where are the tests being executed?

Bit tests components in an isolated component environment. Bit does this to ensure true isolation of components. So if a test process runs successfully, Bit can reproduce it anywhere.

Defining a Tester

Every component can have a tester. Bit uses a global tester configuration for a workspace. Bit propagates the global configuration to each component tracked in that workspace.
Configure a global tester with the --tester flag when importing a compiler component.

$ bit import bit.envs/testers/mocha --tester
the following component environments were installed
- bit.envs/testers/mocha@0.0.7

Adding test/spec files to your components

We mark components' test files by using the --tests option with bit add:

bit add src/foo.js --tests test/foo-test.js

For more details about marking files as test files, see here.

Testing a component

Use bit test to test components that have an associated tester and test files:

$ bit test foo/bar
foo/bar
tests passed
file: dist/test/bar.test.js
total duration - 4ms

✔   bar should do nothing - 1ms

Note

If a component has a compiler, Bit will trigger it prior to running the component's tests.

Testers maintained by bit.dev

Find a list of Testers maintained by the bit.dev here.

  • Mocha.
  • Jest.
← CompilingVersioning →
  • Basics of testing Components
    • Where are the tests being executed?
  • Defining a Tester
  • Adding test/spec files to your components
  • Testing a component
  • Testers maintained by bit.dev
Docs
bit.dev
bit.devSupportTerms and PrivacySLA
Community
SlackTwitter
More
Star
Copyright © 2022 bit.dev