Skip to content

Commit

Permalink
test: add test case for test without describe
Browse files Browse the repository at this point in the history
  • Loading branch information
Dunqing committed Oct 5, 2023
1 parent 540ca84 commit 29ee8be
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/core/test/test-extend.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,3 +303,26 @@ describe('test.extend()', () => {
})
})
})

// test extend with top level test
const numbers: number[] = []
const teardownFn = vi.fn()
const teardownTest = test.extend<{
numbers: number[]
}>({
numbers: async ({}, use) => {
numbers.push(1, 2, 3)
await use(numbers)
numbers.splice(0, numbers.length)
teardownFn()
},
})

teardownTest('test without describe', ({ numbers }) => {
expect(numbers).toHaveLength(3)
})

test('teardown should be called once time', () => {
expect(numbers).toHaveLength(0)
expect(teardownFn).toBeCalledTimes(1)
})

0 comments on commit 29ee8be

Please sign in to comment.