Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should vi.setConfig({ sequence: { shuffle: false } }) be in RuntimeConfig TypeScript type? #7199

Open
6 tasks done
andykenward opened this issue Jan 9, 2025 · 1 comment

Comments

@andykenward
Copy link

Describe the bug

When setting sequence.shuffle via the cli or vitest.config.ts. Should you be able to override this in a test file via

vi.setConfig({
  sequence: {
    shuffle: false
  }
});

The above does indeed overrides the cli or vitest.config.ts. But the TypeScript types for RuntimeConfig does not allow this. There is a TypeScript error of

Object literal may only specify known properties, and 'shuffle' does not exist in type '{ hooks?: SequenceHooks | undefined; }'.ts(2353)

I see in v3 of Vitest there will be feat(runner)!: support describe(..., { shuffle: boolean }) and inherit from parent suite

 describe('not random', { shuffle: false }, () => {
    test('in order 5.1', async () => { /* ... */ })
    test('in order 5.2', async () => { /* ... */ })
  })

Should v3 TypeScript types for RuntimeConfig support shuffle as well?

Reproduction

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

System Info

System:
    OS: macOS 15.2
    CPU: (10) arm64 Apple M1 Max
    Memory: 1.71 GB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.13.1 - ~/.volta/tools/image/node/20.13.1/bin/node
    npm: 10.8.0 - ~/.volta/tools/image/npm/10.8.0/bin/npm
  Browsers:
    Chrome: 131.0.6778.206
    Chrome Canary: 134.0.6946.0
    Firefox: 133.0.3
    Safari: 18.2
  npmPackages:
    @vitest/eslint-plugin: 1.1.18 => 1.1.18
    @vitest/expect: 2.1.8 => 2.1.8
    vitest: 2.1.8 => 2.1.8

Used Package Manager

npm

Validations

@hi-ogawa
Copy link
Contributor

hi-ogawa commented Jan 10, 2025

I think we can expose it if it works, but I'm a bit unsure if it actually works. I vaguely remember that I had to set file.shuffle early before evaluating a test file, so vi.setConfig cannot overwrite 🤔
(Overwriting undefined -> true/false might work, but false -> true and true -> false might not?)

const file = createFileTask(filepath, config.root, config.name, runner.pool)
file.shuffle = config.sequence.shuffle

Can you provide your working example? Also feel free to try a PR with adding a type with test cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants