Skip to content

test.tags options doesn't overwrite inherited suite options #10199

@hi-ogawa

Description

@hi-ogawa

Describe the bug

Found yet another bug that indirectly causes test.sequential vs test(..., { concurrent: false }) behavior divergence.

  • vite.config.ts
import { defineConfig } from 'vitest/config';

export default defineConfig({
  test: {
    tags: [
      {
        name: 'my-tag',
        timeout: 5000,
        repeats: 2,
        concurrent: false,
      },
    ],
  },
});
  • repro.test.ts
import { describe, test } from 'vitest';

describe(
  'with suite options',
  { timeout: 1000, repeats: 1, concurrent: true },
  () => {
    test('bad', { tags: ['my-tag'] }, ({ task }) => {
      console.log({
        timeout: task.timeout,
        repeats: task.repeats,
        concurrent: task.concurrent,
      });
    });
  }
);

describe('without suite options', () => {
  test('good', { tags: ['my-tag'] }, ({ task }) => {
    console.log({
      timeout: task.timeout,
      repeats: task.repeats,
      concurrent: task.concurrent,
    });
  });
});

The test run outputs:

stdout | test/repro.test.ts > with suite options > bad
{ timeout: 1000, repeats: 1, concurrent: true }

stdout | test/repro.test.ts > with suite options > bad
{ timeout: 1000, repeats: 1, concurrent: true }

stdout | test/repro.test.ts > without suite options > good
{ timeout: 5000, repeats: 2, concurrent: undefined }

stdout | test/repro.test.ts > without suite options > good
{ timeout: 5000, repeats: 2, concurrent: undefined }

stdout | test/repro.test.ts > without suite options > good
{ timeout: 5000, repeats: 2, concurrent: undefined }

  test/repro.test.ts (2 tests) 6ms
    with suite options (1)
      bad 3ms (repeat x1)
    without suite options (1)
      good 2ms (repeat x2)

I expect the inner tags options should override suite options.

Reproduction

https://stackblitz.com/edit/vitest-dev-vitest-3uvkkhlm?file=vite.config.ts

System Info

stackblitz

Used Package Manager

npm

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    p3-minor-bugAn edge case that only affects very specific usage (priority)

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions