1- import { expect , test } from '@playwright/test' ;
1+ import { expect , test , type Page } from '@playwright/test' ;
22
33const iframe_selector = 'iframe[src*="webcontainer.io/"]' ;
44
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+
516test . describe . configure ( { mode : 'parallel' } ) ;
617
718test ( '.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
1122
1223 await page . goto ( '/tutorial/welcome-to-svelte' ) ;
1324
25+ // disable animations to prevent flakiness
26+ await disableAnimations ( page ) ;
27+
1428 const iframe_locator = page . frameLocator ( iframe_selector ) ;
1529
1630 // wait for the iframe to load
1731 await iframe_locator . getByText ( 'Welcome!' ) . waitFor ( ) ;
1832
1933 // 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 } ) ;
2337 await page . locator ( 'a' , { hasText : '$env/static/private' } ) . click ( { delay : 200 } ) ;
2438
2539 // wait for the iframe to load
@@ -41,15 +55,18 @@ test('.env file: environment variables are available when switching a tutorial w
4155
4256 await page . goto ( '/tutorial/welcome-to-svelte' ) ;
4357
58+ // disable animations to prevent flakiness
59+ await disableAnimations ( page ) ;
60+
4461 const iframe_locator = page . frameLocator ( iframe_selector ) ;
4562
4663 // wait for the iframe to load
4764 await iframe_locator . getByText ( 'Welcome!' ) . waitFor ( ) ;
4865
4966 // 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 } ) ;
5370 await page . locator ( 'a' , { hasText : '$env/dynamic/private' } ) . click ( { delay : 200 } ) ;
5471
5572 // wait for the iframe to load
0 commit comments