Jest Environment to run the tests as Steps
npm i jest-environment-steps
In Jest, all test
s within a test file run sequentially in the order of their appearance.
But if a test fails, the next tests continue to execute.
For writing tests for a behavior, where each test depends on the success of the previous test, this built-in feature may cause unnecessary tests to run when a test fails.
- Testing the CRUD APIs on a database.
Writing the tests for Create, Read, Update, and Delete in the same sequence make it sense to test all APIs in the same order. When Create fails, there is no point in running tests for Read, Update, and Delete APIs
This library provides a jest environment to add new features to the way the tests are executed.
Inspired by Mocha Steps
- Runs all previous tests, before running the selected test when the testNamePattern argument is provided.
- Skip all next tests, if a test fails
npm i jest-environment-steps
An environment in jest can be applied using either of the below options.
-
Set
testEnvironment
in jest.config.js to enable Steps for all tests// jest.config.js { "testEnvironment": "steps" }
-
Use the docBlock to enable Steps for a specific file
/** * @jest-environment steps */ describe("Tests in this describe runs as steps", () => { ... })
For more configuration on using the environment in jest refer to Jest Config Doc
- This Enables Steps on top of the node environment only
This project is a part of the Open Source Initiative from Sodaru Technologies
Write an email to opensource@sodaru.com for queries on this project