1. jest-serial-runner
Extending the Jest default runner to run tests serially by default
jest-serial-runner
Package: jest-serial-runner
Created by: gabrieli
Last modified: Sun, 13 Nov 2022 03:47:50 GMT
Version: 1.2.1
License: MIT
Downloads: 52,668
Repository: https://github.com/gabrieli/jest-serial-runner

Install

npm install jest-serial-runner
yarn add jest-serial-runner

jest-serial-runner

Extending the Jest default runner to run tests serially by default


Simple wrapper over the default Jest runner that forces serial execution of test files. This is equivalent to running with --runInBand flag by default.

Why? Sometimes you have limited/restricted resources on the test machine (like in a docker container) and running the default jest-runner always runs in parallel unless specified otherwise. Integration tests are another scenario where running concurrent instances causes issues so using this runner ensures only 1 test runs at a time.

Installation

 npm install jest-serial-runner --save-dev

Usage

Option 1: Specify the runner in your Jest config

/* jest.config.json */
{
    // ...
    "runner": "jest-serial-runner"
    // ...
}

Option 2: To specify the runner for a subset of files such as for integration tests.

 /* jest.config.js */
module.exports = {
    // ...
    projects: [
        {
            // Uses the jest default runner for specification testing
            displayName: "UNIT",
            testMatch: ["<rootDir>/src/**/__tests__/*.spec.ts"]
        },
        {
            // Uses the serial runner instead for integration test files
            displayName: "INTEGRATION",
            runner: "jest-serial-runner",
            testMatch: ["<rootDir>/tests/**/*.integration-test.ts"]
        }
    ]
}

Contributors

Thank you to all of our contributors!

PR's & Issue contributions welcome! Please adhere to
contributing guidelines
or your submission will be closed or delayed.

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin