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

Type error when using {retry: 2} in describe() #1998

Closed
6 tasks done
johnfraney opened this issue Sep 7, 2022 · 2 comments · Fixed by #2025
Closed
6 tasks done

Type error when using {retry: 2} in describe() #1998

johnfraney opened this issue Sep 7, 2022 · 2 comments · Fixed by #2025

Comments

@johnfraney
Copy link

Describe the bug

I'm getting a type error when using the new retry option (#1929) of describe():

error TS2554: Expected 1-2 arguments, but got 3

Reproduction

This will run successfully but trigger a type error:

describe('tests', () => {
  ...
}, {retry: 2})

System Info

npx: installed 1 in 1.517s

  System:
    OS: macOS 12.5.1
    CPU: (8) x64 Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz
    Memory: 2.67 GB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 14.18.0 - ~/.nvm/versions/node/v14.18.0/bin/node
    npm: 6.14.15 - ~/.nvm/versions/node/v14.18.0/bin/npm
    Watchman: 2022.05.16.00 - /usr/local/bin/watchman
  Browsers:
    Chrome: 104.0.5112.101
    Firefox Developer Edition: 105.0
    Safari: 15.6.1
  npmPackages:
    @vitejs/plugin-react: ^1.3.0 => 1.3.2 
    vite: ^2.9.5 => 2.9.14 
    vitest: ^0.23.0 => 0.23.1

Used Package Manager

npm

Validations

@bartoszgolebiowski
Copy link
Contributor

Hello,
I just checked this typescript error, and I would like to share my conclusions.
We are missing types for describe section, but the options?: number | TestOptions argument will somehow affect this section.

For this scenario, the retry option will retry describe section 10 times.

let count4 = 0
describe('description retry', () => {
    count4 += 1
    expect(count4).toBe(10)
}, { retry: 10 })

but for this scenario, it will not.

describe('description retry', () => {
  let count4 = 0
  it('retry test fails', () => {
    count4 += 1
    expect(count4).toBe(10)
  })
}, { retry: 10 })

The question is. Should the options?: number | TestOptions from describe section propagate to all tests inside, or this is undocumented behavior and vitest does not want to support it?

@sheremet-va
Copy link
Member

Should the options?: number | TestOptions from describe section propagate to all tests inside, or this is undocumented behavior and vitest does not want to support it?

It should propagate to all tests inside, this is a bug.

@sheremet-va sheremet-va added the bug label Sep 8, 2022
bartoszgolebiowski pushed a commit to bartoszgolebiowski/vitest that referenced this issue Sep 11, 2022
sheremet-va pushed a commit that referenced this issue Sep 13, 2022
close: #1998

Co-authored-by: golebiowskib <bartosz.golebiowski@@ttpsc.pl>
@github-actions github-actions bot locked and limited conversation to collaborators Jun 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants