Skip to content

Commit

Permalink
fix(runner): suite options do not propagate to nested suites (fix: #3467
Browse files Browse the repository at this point in the history
) (#3473)
  • Loading branch information
xsjcTony committed May 31, 2023
1 parent 4c9a7d5 commit 9fb9dac
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
7 changes: 3 additions & 4 deletions packages/runner/src/suite.ts
Expand Up @@ -199,10 +199,9 @@ function createSuite() {
if (typeof options === 'number')
options = { timeout: options }

if (currentSuite && typeof currentSuite.options?.repeats === 'number') {
// inherit repeats from current suite
options = { repeats: currentSuite.options.repeats, ...options }
}
// inherit options from current suite
if (currentSuite?.options)
options = { ...currentSuite.options, ...options }

return createSuiteCollector(name, factory, mode, this.concurrent, this.shuffle, this.each, options)
}
Expand Down
23 changes: 23 additions & 0 deletions test/core/test/propagate-options-nested-suite.test.ts
@@ -0,0 +1,23 @@
import { describe, expect, it } from 'vitest'

describe(
'suite name',
() => {
let outerCount = 0

it('should retry until success', () => {
outerCount++
expect(outerCount).toBe(5)
})

describe('nested', () => {
let innerCount = 0

it('should retry until success (nested)', () => {
innerCount++
expect(innerCount).toBe(5)
})
})
},
{ retry: 10 },
)

0 comments on commit 9fb9dac

Please sign in to comment.