@@ -50,11 +50,17 @@ describe('app-ssr-i18n', () => {
5050 const text = await page . $ ( '#key' ) ;
5151 const targetText = await page . evaluate ( el => el ?. textContent , text ) ;
5252 expect ( targetText ?. trim ( ) ) . toEqual ( '你好,世界' ) ;
53- page . click ( '#en-button' ) ;
54- await new Promise ( resolve => setTimeout ( resolve , 3000 ) ) ;
55- const textEn = await page . $ ( '#key' ) ;
56- const targetTextEn = await page . evaluate ( el => el ?. textContent , textEn ) ;
57- expect ( targetTextEn ?. trim ( ) ) . toEqual ( 'Hello World' ) ;
53+ await page . click ( '#en-button' ) ;
54+ await new Promise ( resolve => setTimeout ( resolve , 5000 ) ) ;
55+ await page . waitForFunction (
56+ ( ) => {
57+ const el = document . querySelector ( '#key' ) ;
58+ return (
59+ el && el . textContent !== null && el . textContent === 'Hello World'
60+ ) ;
61+ } ,
62+ { timeout : 10000 } ,
63+ ) ;
5864 } ) ;
5965 test ( 'page-en' , async ( ) => {
6066 const response = await page . goto ( `http://localhost:${ appPort } /en` , {
@@ -65,10 +71,14 @@ describe('app-ssr-i18n', () => {
6571 const text = await page . $ ( '#key' ) ;
6672 const targetText = await page . evaluate ( el => el ?. textContent , text ) ;
6773 expect ( targetText ?. trim ( ) ) . toEqual ( 'Hello World' ) ;
68- page . click ( '#zh-button' ) ;
69- await new Promise ( resolve => setTimeout ( resolve , 3000 ) ) ;
70- const textZh = await page . $ ( '#key' ) ;
71- const targetTextZh = await page . evaluate ( el => el ?. textContent , textZh ) ;
72- expect ( targetTextZh ?. trim ( ) ) . toEqual ( '你好,世界' ) ;
74+ await page . click ( '#zh-button' ) ;
75+ await new Promise ( resolve => setTimeout ( resolve , 5000 ) ) ;
76+ await page . waitForFunction (
77+ ( ) => {
78+ const el = document . querySelector ( '#key' ) ;
79+ return el && el . textContent !== null && el . textContent === '你好,世界' ;
80+ } ,
81+ { timeout : 10000 } ,
82+ ) ;
7383 } ) ;
7484} ) ;
0 commit comments