From 9fb9dacbb738a64f2b6d99b738c701fef72f5652 Mon Sep 17 00:00:00 2001 From: Aelita <45784210+xsjcTony@users.noreply.github.com> Date: Thu, 1 Jun 2023 00:12:47 +1000 Subject: [PATCH] fix(runner): suite options do not propagate to nested suites (fix: #3467) (#3473) --- packages/runner/src/suite.ts | 7 +++--- .../propagate-options-nested-suite.test.ts | 23 +++++++++++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 test/core/test/propagate-options-nested-suite.test.ts diff --git a/packages/runner/src/suite.ts b/packages/runner/src/suite.ts index 2eaa9cf792e0..f28162f2f236 100644 --- a/packages/runner/src/suite.ts +++ b/packages/runner/src/suite.ts @@ -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) } diff --git a/test/core/test/propagate-options-nested-suite.test.ts b/test/core/test/propagate-options-nested-suite.test.ts new file mode 100644 index 000000000000..4c10b183e508 --- /dev/null +++ b/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 }, +)