Skip to content

Commit

Permalink
chore: fix the error
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Feb 12, 2024
1 parent d5d63cd commit a8fd107
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions packages/runner/src/suite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,14 +262,20 @@ function createSuite() {
if (Array.isArray(cases) && args.length)
cases = formatTemplateString(cases, args)

return (name: string | Function, fn: (...args: T[]) => void, options?: number | TestOptions) => {
return (name: string | Function, optionsOrFn: ((...args: T[]) => void) | TestOptions, fnOrOptions?: ((...args: T[]) => void) | number | TestOptions) => {
const _name = formatName(name)
const arrayOnlyCases = cases.every(Array.isArray)

const { options, handler } = parseArguments(
optionsOrFn,
fnOrOptions,
)

cases.forEach((i, idx) => {
const items = Array.isArray(i) ? i : [i]
arrayOnlyCases
? suite(formatTitle(_name, items, idx), () => fn(...items), options)
: suite(formatTitle(_name, items, idx), () => fn(i), options)
? suite(formatTitle(_name, items, idx), options, () => handler(...items))
: suite(formatTitle(_name, items, idx), options, () => handler(i))
})

this.setContext('each', undefined)
Expand Down Expand Up @@ -311,8 +317,8 @@ export function createTaskCollector(
const items = Array.isArray(i) ? i : [i]

arrayOnlyCases
? test(formatTitle(_name, items, idx), () => handler(...items), options)
: test(formatTitle(_name, items, idx), () => handler(i), options)
? test(formatTitle(_name, items, idx), options, () => handler(...items))
: test(formatTitle(_name, items, idx), options, () => handler(i))
})

this.setContext('each', undefined)
Expand Down

0 comments on commit a8fd107

Please sign in to comment.