@taqueria/plugin-jest
Jest Plugin
The @taqueria/plugin-jest
plugin provides the taq test
task which provides a means to initialize Jest test directories and run Jest tests
Requirements
- Taqueria v0.26.0 or later
- Node.js v16.16 or later. (v17.x.x or later is not supported)
Installation
To install the Jest plugin on a Taqueria project, run:
taq install @taqueria/plugin-jest
Usage
The Jest plugin will automatically initialize a Jest tests folder when you run taq test <test-folder>
The easiest way to start using the plugin is to:
- Create a new folder in the root of your project
tests
- Add one or more tests to the folder
- Run
taq test tests
Initializing Partitions
The Jest plugin uses partitions. These are just directories with their own JEST config but allow you to group and manage your tests with great flexibility. This allows you to segment and run tests in different buckets such as:
- By type (unit tests, integration tests, acceptance tests, e2e tests)
- Structural (dapp, smart contract, serverless functions)
To create a new partition (initialized test folder), run:
taq test --init
This will do several things:
- Create a new folder (in this case it uses the default folder
tests
) - Create a Jest configuration in the folder
- Create a global Jest configuration file in
.taq/jest.config.js
You can create any number of partitions. By default there are no partitions
To create additional partitions, simply run:
taq test [partitionName]
Running Jest tests
The taq test [partitionName]
task will run the Jest tests associated with a particular partition
Create tests in that folder, for example creating the test file tests/example.spec.ts
Jest Configuration
A Global Config for Jest is created in the project's Taq folder: .taq/jest.config.js
Each partition will have it's own Jest configuration file (tests/jest.config.js
)
The Jest configurations cascade down from the global config. If you want to override a value in the global config, simply define it in the partition config. The partition config will override the global config
Plugin Architecture
This is a plugin developed for Taqueria built on NodeJS using the Taqueria Node SDK and distributed via NPM