Skip to content

Commit 5ce0045

Browse files
committed
fixup: further test refinements
1 parent b9a6131 commit 5ce0045

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

src/__tests__/auto-cleanup.test.js

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,34 +23,28 @@ describe('auto-cleanup', () => {
2323

2424
test('calls afterEach with cleanup if globally defined', async () => {
2525
const { render } = await importSvelteTestingLibrary()
26-
const { default: Comp } = await import('./fixtures/Comp.svelte')
27-
28-
render(Comp, { props: { name: 'world' } })
2926

3027
expect(globalAfterEach).toHaveBeenCalledTimes(1)
3128
expect(globalAfterEach).toHaveBeenLastCalledWith(expect.any(Function))
29+
const globalCleanup = globalAfterEach.mock.lastCall[0]
3230

33-
await globalAfterEach.mock.lastCall[0]()
31+
const { default: Comp } = await import('./fixtures/Comp.svelte')
32+
render(Comp, { props: { name: 'world' } })
33+
await globalCleanup()
3434

3535
expect(document.body).toBeEmptyDOMElement()
3636
})
3737

3838
test('does not call afterEach if process STL_SKIP_AUTO_CLEANUP is set', async () => {
3939
process.env.STL_SKIP_AUTO_CLEANUP = 'true'
4040

41-
const { render } = await importSvelteTestingLibrary()
42-
const { default: Comp } = await import('./fixtures/Comp.svelte')
43-
44-
render(Comp, { props: { name: 'world' } })
41+
await importSvelteTestingLibrary()
4542

4643
expect(globalAfterEach).toHaveBeenCalledTimes(0)
4744
})
4845

4946
test('does not call afterEach if you import from `pure`', async () => {
50-
const { render } = await importSvelteTestingLibraryPure()
51-
const { default: Comp } = await import('./fixtures/Comp.svelte')
52-
53-
render(Comp, { props: { name: 'world' } })
47+
await importSvelteTestingLibraryPure()
5448

5549
expect(globalAfterEach).toHaveBeenCalledTimes(0)
5650
})

0 commit comments

Comments
 (0)