Skip to content

Commit 15c091a

Browse files
authored
fix: correctly inherit test options on extended tests (#8618)
1 parent a9006b3 commit 15c091a

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

packages/runner/src/suite.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ function parseArguments<T extends (...args: any[]) => any>(
245245
optionsOrFn: T | object | undefined,
246246
timeoutOrTest: T | number | undefined,
247247
) {
248-
if (typeof timeoutOrTest === 'object') {
248+
if (timeoutOrTest != null && typeof timeoutOrTest === 'object') {
249249
throw new TypeError(`Siganture "test(name, fn, { ... })" was deprecated in Vitest 3 and removed in Vitest 4. Please, provide options as a second argument instead.`)
250250
}
251251

@@ -790,9 +790,7 @@ export function createTaskCollector(
790790
scopedFixtures,
791791
)
792792
}
793-
const { handler, options } = parseArguments(optionsOrFn, optionsOrTest)
794-
const timeout = options.timeout ?? collector.options?.timeout ?? runner?.config.testTimeout
795-
originalWrapper.call(context, formatName(name), handler, timeout)
793+
originalWrapper.call(context, formatName(name), optionsOrFn, optionsOrTest)
796794
}, _context)
797795
}
798796

test/core/test/retry.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,16 @@ describe.each([
6464
expect(flag3).toBe(false)
6565
})
6666
})
67+
68+
describe('extended tests keep the options', () => {
69+
const test$ = it.extend({
70+
extended: true,
71+
})
72+
73+
test$('inherits all options', { retry: 2, repeats: 1, timeout: 3456 }, ({ task, extended }) => {
74+
expect(task.retry).toBe(2)
75+
expect(task.repeats).toBe(1)
76+
expect(task.timeout).toBe(3456)
77+
expect(extended).toBe(true)
78+
})
79+
})

0 commit comments

Comments
 (0)