Skip to content

Fixture Scope Mismatch Issue #10027

@alexvictoor

Description

@alexvictoor

Describe the bug

When fixtures with different scopes are used, specifically, one with a 'worker' scope and another with the default 'test' scope (and the 'auto' flag set to 'true'), the fixture with the 'worker' scope cannot be accessed or utilized within a "beforeAll" hook.

Reproduction

import { describe, test } from 'vitest';

const it = test
  .extend('fakeTestFixture', { auto: true }, () => {})
  .extend('fakeWorkerFixture', { scope: 'worker' }, () => {
    console.log('fakeWorkerFixture');
    return 'hello';
  });

describe('scope mismatch', () => {
  it.beforeAll(({ fakeWorkerFixture }) => {
    console.log('before all ' + fakeWorkerFixture);
  });

  it('should work', () => {});
});

https://stackblitz.com/edit/vitest-dev-vitest-vp84tpwo?file=test%2Fscope.test.ts,package-lock.json&initialPath=__vitest__/

System Info

System:
    OS: macOS 26.3.1
    CPU: (12) arm64 Apple M3 Pro
    Memory: 262.59 MB / 36.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 24.10.0 - /Users/avictoor/.nvm/versions/node/v24.10.0/bin/node
    Yarn: 4.12.0 - /Users/avictoor/.nvm/versions/node/v24.10.0/bin/yarn
    npm: 11.6.1 - /Users/avictoor/.nvm/versions/node/v24.10.0/bin/npm
    bun: 1.2.4 - /Users/avictoor/.bun/bin/bun
  Browsers:
    Chrome: 146.0.7680.165
    Edge: 146.0.3856.84
    Firefox: 149.0
    Safari: 26.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

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions