Skip to content

test.scoped() values are not always scoped to the current suite #7813

@limulus

Description

@limulus

Describe the bug

Between the docs and this test I would expect both of the following tests to pass, but the second test fails.

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

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

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

describe('foo is left as default of false', () => {
  extendedTest('foo is false', ({ foo }) => {
    expect(foo).toBe(false);
  });
});

Reproduction

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

System Info

System:
    OS: macOS 15.3.2
    CPU: (10) arm64 Apple M1 Pro
    Memory: 154.95 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

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