@jest/test-sequencer

  • Version 29.7.0
  • Published
  • 13.6 kB
  • 4 dependencies
  • MIT license

Install

npm i @jest/test-sequencer
yarn add @jest/test-sequencer
pnpm add @jest/test-sequencer

Overview

Overview not available.

Index

Variables

variable FAIL

const FAIL: number;

    variable SUCCESS

    const SUCCESS: number;

      Classes

      class TestSequencer

      class TestSequencer {}
      • The TestSequencer will ultimately decide which tests should run first. It is responsible for storing and reading from a local cache map that stores context information for a given test, such as how long it took to run during the last run and if it has failed or not. Such information is used on: TestSequencer.sort(tests: Array) to sort the order of the provided tests.

        After the results are collected, TestSequencer.cacheResults(tests: Array, results: AggregatedResult) is called to store/update this information on the cache map.

      method allFailedTests

      allFailedTests: (tests: Array<Test>) => Array<Test> | Promise<Array<Test>>;

        method cacheResults

        cacheResults: (tests: Array<Test>, results: AggregatedResult) => void;

          method shard

          shard: (
          tests: Array<Test>,
          options: ShardOptions
          ) => Array<Test> | Promise<Array<Test>>;
          • Select tests for shard requested via --shard=shardIndex/shardCount Sharding is applied before sorting

            Parameter tests

            All tests

            Parameter options

            shardIndex and shardIndex to select

            Example 1

            class CustomSequencer extends Sequencer {
            shard(tests, { shardIndex, shardCount }) {
            const shardSize = Math.ceil(tests.length / options.shardCount);
            const shardStart = shardSize * (options.shardIndex - 1);
            const shardEnd = shardSize * options.shardIndex;
            return [...tests]
            .sort((a, b) => (a.path > b.path ? 1 : -1))
            .slice(shardStart, shardEnd);
            }
            }

          method sort

          sort: (tests: Array<Test>) => Array<Test> | Promise<Array<Test>>;
          • Sort test to determine order of execution Sorting is applied after sharding

            Parameter tests

            class CustomSequencer extends Sequencer {
            sort(tests) {
            const copyTests = Array.from(tests);
            return [...tests].sort((a, b) => (a.path > b.path ? 1 : -1));
            }
            }

          Type Aliases

          type ShardOptions

          type ShardOptions = {
          shardIndex: number;
          shardCount: number;
          };

            Package Files (1)

            Dependencies (4)

            Dev Dependencies (2)

            Peer Dependencies (0)

            No peer dependencies.

            Badge

            To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

            You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@jest/test-sequencer.

            • Markdown
              [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@jest/test-sequencer)
            • HTML
              <a href="https://www.jsdocs.io/package/@jest/test-sequencer"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>