Skip to content

Nested suites run tests serially inside a concurrent suite #4480

@dsyddall

Description

@dsyddall

Describe the bug

The documentation for describe.sequential states that it has the function of running tests serially within a describe.concurrent suite. However, there is no difference in behaviour between describe and describe.sequential. Both types of suite run tests serially, making describe.sequential have no effect.

For example, both of the following tests have the same behaviour:

With describe.sequential:

describe.concurrent('concurrent suite', () => {
  test('concurrent test 1', async () => { /* ... */ })
  test('concurrent test 2', async () => { /* ... */ })

  describe.sequential('sequential suite', () => {
    test('sequential test 1', async () => { /* ... */ })
    test('sequential test 2', async () => { /* ... */ })
  })
})

With describe:

describe.concurrent('concurrent suite', () => {
  test('concurrent test 1', async () => { /* ... */ })
  test('concurrent test 2', async () => { /* ... */ })

  describe('sequential suite', () => {
    test('sequential test 1', async () => { /* ... */ })
    test('sequential test 2', async () => { /* ... */ })
  })
})

Reproduction: https://stackblitz.com/edit/vitest-dev-vitest-ri5bfg?file=nested-concurrent.test.ts

Expected behaviour

Tests within nested suites inside a concurrent suite run concurrently but can be changed to run sequentially using describe.sequential. I.e.:

describe.concurrent('concurrent suite', () => {
  test('concurrent test 1', async () => { /* ... */ })
  test('concurrent test 2', async () => { /* ... */ })

  describe('nested concurrent suite', () => {
    test('concurrent test 3', async () => { /* ... */ })
    test('concurrent test 4', async () => { /* ... */ })
  })

  describe.sequential('sequential suite', () => {
    test('sequential test 1', async () => { /* ... */ })
    test('sequential test 2', async () => { /* ... */ })
  })
})

Proposed fix

Ensure that concurrent/sequential options are inherited from the parent suite.

Reproduction

https://stackblitz.com/edit/vitest-dev-vitest-ri5bfg?file=nested-concurrent.test.ts

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 18.18.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 9.4.2 - /usr/local/bin/npm
    pnpm: 8.9.2 - /usr/local/bin/pnpm
  npmPackages:
    @vitest/ui: 1.0.0-beta.4 => 1.0.0-beta.4 
    vite: latest => 4.5.0 
    vitest: 1.0.0-beta.4 => 1.0.0-beta.4

Used Package Manager

npm

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions