11import { afterEach , beforeEach , describe , expect , test , vi } from 'vitest'
22
3- import Comp from './fixtures/Comp.svelte'
43import { IS_SVELTE_5 } from './utils.js'
54
65const importSvelteTestingLibrary = async ( ) =>
@@ -24,12 +23,14 @@ describe('auto-cleanup', () => {
2423
2524 test ( 'calls afterEach with cleanup if globally defined' , async ( ) => {
2625 const { render } = await importSvelteTestingLibrary ( )
26+ const { default : Comp } = await import ( './fixtures/Comp.svelte' )
27+
2728 render ( Comp , { props : { name : 'world' } } )
2829
2930 expect ( globalAfterEach ) . toHaveBeenCalledTimes ( 1 )
3031 expect ( globalAfterEach ) . toHaveBeenLastCalledWith ( expect . any ( Function ) )
3132
32- await afterEach . mock . lastCall [ 0 ] ( )
33+ await globalAfterEach . mock . lastCall [ 0 ] ( )
3334
3435 expect ( document . body ) . toBeEmptyDOMElement ( )
3536 } )
@@ -38,13 +39,17 @@ describe('auto-cleanup', () => {
3839 process . env . STL_SKIP_AUTO_CLEANUP = 'true'
3940
4041 const { render } = await importSvelteTestingLibrary ( )
42+ const { default : Comp } = await import ( './fixtures/Comp.svelte' )
43+
4144 render ( Comp , { props : { name : 'world' } } )
4245
4346 expect ( globalAfterEach ) . toHaveBeenCalledTimes ( 0 )
4447 } )
4548
4649 test ( 'does not call afterEach if you import from `pure`' , async ( ) => {
4750 const { render } = await importSvelteTestingLibraryPure ( )
51+ const { default : Comp } = await import ( './fixtures/Comp.svelte' )
52+
4853 render ( Comp , { props : { name : 'world' } } )
4954
5055 expect ( globalAfterEach ) . toHaveBeenCalledTimes ( 0 )
0 commit comments