Skip to content

Commit

Permalink
fix(runner): preserve fixtures when calling runif and skipif (fix #4585
Browse files Browse the repository at this point in the history
…) (#4591)
  • Loading branch information
dsyddall committed Nov 27, 2023
1 parent a150c19 commit 515eadf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/runner/src/suite.ts
Expand Up @@ -269,8 +269,12 @@ export function createTaskCollector(
}
}

taskFn.skipIf = (condition: any) => (condition ? test.skip : test) as TestAPI
taskFn.runIf = (condition: any) => (condition ? test : test.skip) as TestAPI
taskFn.skipIf = function (this: TestAPI, condition: any) {
return condition ? this.skip : this
}
taskFn.runIf = function (this: TestAPI, condition: any) {
return condition ? this : this.skip
}

taskFn.extend = function (fixtures: Fixtures<Record<string, any>>) {
const _context = mergeContextFixtures(fixtures, context)
Expand Down
8 changes: 8 additions & 0 deletions test/core/test/fixture-initialization.test.ts
Expand Up @@ -82,6 +82,14 @@ describe('fixture initialization', () => {
})
})

myTest.runIf(true)('fixtures work with runIf', ({ a }) => {
expect(a).toBe(1)
})

myTest.skipIf(false)('fixtures work with skipIf', ({ a }) => {
expect(a).toBe(1)
})

describe('fixture dependency', () => {
myTest2('b => a', ({ b }) => {
expect(b).toBe('2')
Expand Down

0 comments on commit 515eadf

Please sign in to comment.