1
- import { expect , test } from '@playwright/test' ;
1
+ import { expect , test , type Page } from '@playwright/test' ;
2
2
3
3
const iframe_selector = 'iframe[src*="webcontainer.io/"]' ;
4
4
5
+ async function disableAnimations ( page : Page ) {
6
+ await page . addStyleTag ( {
7
+ content : `
8
+ *, *::before, *::after {
9
+ animation-duration: 0s !important;
10
+ transition-duration: 0s !important;
11
+ }
12
+ `
13
+ } ) ;
14
+ }
15
+
5
16
test . describe . configure ( { mode : 'parallel' } ) ;
6
17
7
18
test ( '.env file: no timeout error occurs when switching a tutorials without a .env file to one with it' , async ( {
@@ -11,15 +22,18 @@ test('.env file: no timeout error occurs when switching a tutorials without a .e
11
22
12
23
await page . goto ( '/tutorial/welcome-to-svelte' ) ;
13
24
25
+ // disable animations to prevent flakiness
26
+ await disableAnimations ( page ) ;
27
+
14
28
const iframe_locator = page . frameLocator ( iframe_selector ) ;
15
29
16
30
// wait for the iframe to load
17
31
await iframe_locator . getByText ( 'Welcome!' ) . waitFor ( ) ;
18
32
19
33
// switch to another tutorial with a .env file
20
- await page . click ( 'header > h1' , { delay : 200 } ) ;
21
- await page . locator ( 'button' , { hasText : 'Part 4: Advanced SvelteKit' } ) . click ( { delay : 200 } ) ;
22
- await page . locator ( 'button' , { hasText : 'Environment variables' } ) . click ( { delay : 200 } ) ;
34
+ await page . click ( 'header > button > h1' , { delay : 200 } ) ;
35
+ await page . getByRole ( 'button' , { name : 'Part 4: Advanced SvelteKit' } ) . click ( { delay : 200 } ) ;
36
+ await page . getByRole ( 'button' , { name : 'Environment variables' } ) . click ( { delay : 200 } ) ;
23
37
await page . locator ( 'a' , { hasText : '$env/static/private' } ) . click ( { delay : 200 } ) ;
24
38
25
39
// wait for the iframe to load
@@ -41,15 +55,18 @@ test('.env file: environment variables are available when switching a tutorial w
41
55
42
56
await page . goto ( '/tutorial/welcome-to-svelte' ) ;
43
57
58
+ // disable animations to prevent flakiness
59
+ await disableAnimations ( page ) ;
60
+
44
61
const iframe_locator = page . frameLocator ( iframe_selector ) ;
45
62
46
63
// wait for the iframe to load
47
64
await iframe_locator . getByText ( 'Welcome!' ) . waitFor ( ) ;
48
65
49
66
// switch to another tutorial with a .env file
50
- await page . click ( 'header > h1' , { delay : 200 } ) ;
51
- await page . locator ( 'button' , { hasText : 'Part 4: Advanced SvelteKit' } ) . click ( { delay : 200 } ) ;
52
- await page . locator ( 'button' , { hasText : 'Environment variables' } ) . click ( { delay : 200 } ) ;
67
+ await page . click ( 'header > button > h1' , { delay : 200 } ) ;
68
+ await page . getByRole ( 'button' , { name : 'Part 4: Advanced SvelteKit' } ) . click ( { delay : 200 } ) ;
69
+ await page . getByRole ( 'button' , { name : 'Environment variables' } ) . click ( { delay : 200 } ) ;
53
70
await page . locator ( 'a' , { hasText : '$env/dynamic/private' } ) . click ( { delay : 200 } ) ;
54
71
55
72
// wait for the iframe to load
0 commit comments