1
1
import { act , render , screen } from '@testing-library/svelte'
2
- import { VERSION as SVELTE_VERSION } from 'svelte/compiler'
3
- import { describe , expect , test , vi } from 'vitest'
2
+ import { beforeAll , describe , expect , test , vi } from 'vitest'
4
3
5
- import Comp from './fixtures/Comp.svelte'
4
+ import { IS_SVELTE_5 } from './utils.js'
5
+
6
+ describe . each ( [
7
+ {
8
+ name : 'legacy' ,
9
+ componentImport : './fixtures/Comp.svelte' ,
10
+ } ,
11
+ ...( IS_SVELTE_5
12
+ ? [
13
+ {
14
+ name : 'runes' ,
15
+ componentImport : './fixtures/CompRunes.svelte' ,
16
+ } ,
17
+ ]
18
+ : [ ] ) ,
19
+ ] ) ( 'rerender $name component' , ( { name, componentImport, accessors } ) => {
20
+ let Comp
21
+
22
+ beforeAll ( async ( ) => {
23
+ Comp = await import ( componentImport )
24
+ } )
6
25
7
- describe ( 'rerender' , ( ) => {
8
26
test ( 'updates props' , async ( ) => {
9
27
const { rerender } = render ( Comp , { name : 'World' } )
10
28
const element = screen . getByText ( 'Hello World!' )
@@ -29,13 +47,12 @@ describe('rerender', () => {
29
47
)
30
48
} )
31
49
32
- test ( 'change props with accessors' , async ( ) => {
33
- const { component, getByText } = render (
34
- Comp ,
35
- SVELTE_VERSION < '5'
36
- ? { accessors : true , props : { name : 'World' } }
37
- : { name : 'World' }
38
- )
50
+ test . skipIf ( name === 'runes' ) ( 'change props with accessors' , async ( ) => {
51
+ const componentOptions = IS_SVELTE_5
52
+ ? { name : 'World' }
53
+ : { accessors : true , props : { name : 'World' } }
54
+
55
+ const { component, getByText } = render ( Comp , componentOptions )
39
56
const element = getByText ( 'Hello World!' )
40
57
41
58
expect ( element ) . toBeInTheDocument ( )
0 commit comments