Skip to content

test.scoped() does not cascade to child suites #7793

@limulus

Description

@limulus

Describe the bug

Using the new test.scoped() method only seems to work for the current suite and not any child suites.

The docs seem to indicate that this test should pass, but it fails:

const extendedTest = test.extend<{ foo: boolean }>({
  foo: false,
});

describe('top level', () => {
  extendedTest.scoped({ foo: true });

  describe('second level', () => {
    extendedTest('foo is true', ({ foo }) => {
      expect(foo).toBe(true);
    });
  });
});

Reproduction

https://stackblitz.com/edit/vitest-dev-vitest-fedbxgs5?file=test%2Fsuite.test.ts

System Info

System:
    OS: macOS 15.3.2
    CPU: (10) arm64 Apple M1 Pro
    Memory: 108.75 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.14.0 - ~/Library/NodeJS/bin/node
    Yarn: 1.22.19 - ~/Library/NodeJS/bin/yarn
    npm: 10.9.2 - ~/Library/NodeJS/bin/npm
  Browsers:
    Chrome: 134.0.6998.166
    Edge: 134.0.3124.95
    Safari: 18.3.1
  npmPackages:
    @vitest/coverage-v8: ^3.1.1 => 3.1.1 
    vitest: ^3.1.1 => 3.1.1

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

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions