Giter Site home page Giter Site logo

jest-serial-runner's Introduction

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.

jest-serial-runner's People

Contributors

codejedi365 avatar dependabot[bot] avatar dzcpy avatar evandwight avatar gabrieli avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

jest-serial-runner's Issues

The automated release is failing 🚨

🚨 The automated release from the master branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you can benefit from your bug fixes and new features again.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can fix this πŸ’ͺ.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here are some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


No npm token specified.

An npm token must be created and set in the NPM_TOKEN environment variable on your CI environment.

Please make sure to create an npm token and to set it in the NPM_TOKEN environment variable on your CI environment. The token must allow to publish to the registry https://registry.npmjs.org/.


Good luck with your project ✨

Your semantic-release bot πŸ“¦πŸš€

stopped working with jest 25.4.0

When using jest 25, the following error occurs:

    TypeError: runtime.unstable_shouldLoadAsEsm is not a function

      at jasmine2 (node_modules/jest-config/node_modules/jest-jasmine2/build/index.js:188:25)

This is because the runner is using old jest-runner.
I think the best solution is to put the jest-runner as peer dependency with no semver restrictions

SerialRunner fails to import TestRunner base class

I'm not sure what I am doing wrong with the configuration I'm using but I keep getting a runtime TypeError message when running jest in a project configuration.

> [email protected] test
> jest

TestRunner = [object Object]
TypeError: Class extends value #<Object> is not a constructor or null
    at Object.<anonymous> (/Users/codejedi365/Development/workbench/workspace/eslint-plugin-testcafe-community/node_modules/jest-serial-runner/index.js:4:28)
    at Module._compile (internal/modules/cjs/loader.js:1072:14)
    at Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
    at newLoader (/Users/codejedi365/Development/workbench/workspace/eslint-plugin-testcafe-community/node_modules/pirates/lib/index.js:104:7)
    at Object.newLoader (/Users/codejedi365/Development/workbench/workspace/eslint-plugin-testcafe-community/node_modules/pirates/lib/index.js:104:7)
    at Module.load (internal/modules/cjs/loader.js:937:32)
    at Function.Module._load (internal/modules/cjs/loader.js:778:12)
    at Module.require (internal/modules/cjs/loader.js:961:19)
    at require (internal/modules/cjs/helpers.js:92:18)
    at requireOrImportModule (/Users/codejedi365/Development/workbench/workspace/eslint-plugin-testcafe-community/node_modules/jest-util/build/requireOrImportModule.js:53:28)


Test Suites: 0 of 7 total
Tests:       0 total
Snapshots:   0 total
Time:        0 s, estimated 12 s

My project configuration:

// jest.config.js
module.exports = {
    projects: [
        {
            displayName: "unit-tests",
            testMatch: ["<rootDir>/tests/**/*.test.ts"],
            preset: "ts-jest",
            collectCoverage: true,
            collectCoverageFrom: [
                "lib/**/*.ts",
                "index.ts",
                "!**/node_modules/**"
            ]
        },
        {
            // Tests to run in serial
            displayName: "integration-tests",
            collectCoverage: false,
            preset: "ts-jest",
            runner: "jest-serial-runner",
            testMatch: ["<rootDir>/tests/**/*.serial-test.ts"]
        }
    ],
    testPathIgnorePatterns: ["<rootDir>/tests/fixtures/", "<rootDir>/example/"]
};

I suspect it might have something to do with the fact I'm using ts-jest but I'm unfamiliar of how this changes the runtime execution.

Project URL: https://github.com/testcafe-community/eslint-plugin-testcafe-community/tree/integration-tests

Not reporting coverage data with Jest 26

With jest-26.0.1, all test ran using the jest-serial-runner do not report any coverage statistics. Instead this is what is reported:

=============================== Coverage summary ===============================
Statements   : Unknown% ( 0/0 )
Branches     : Unknown% ( 0/0 )
Functions    : Unknown% ( 0/0 )
Lines        : Unknown% ( 0/0 )
================================================================================

Any ideas on how to fix this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.