@@ -86,25 +86,11 @@ const runTests = (mode = 'dev', didReload = false) => {
86
86
} )
87
87
88
88
it ( 'should inline global values during build' , async ( ) => {
89
- // make sure to build page
90
- await renderViaHTTP ( appPort , '/global' )
89
+ const browser = await webdriver ( appPort , '/global' )
91
90
92
- const buildManifest = require ( join (
93
- __dirname ,
94
- '../app/.next/build-manifest.json'
95
- ) )
96
-
97
- const pageFile = buildManifest . pages [ '/global' ] . find ( ( filename ) =>
98
- filename . includes ( 'pages/global' )
99
- )
100
-
101
- // read client bundle contents since a server side render can
102
- // have the value available during render but it not be injected
103
- const bundleContent = await fs . readFile (
104
- join ( appDir , '.next' , pageFile ) ,
105
- 'utf8'
91
+ expect ( await browser . waitForElementByCss ( '#global-value' ) . text ( ) ) . toBe (
92
+ 'another'
106
93
)
107
- expect ( bundleContent ) . toContain ( 'another' )
108
94
} )
109
95
110
96
it ( 'should provide env for SSG' , async ( ) => {
@@ -295,7 +281,9 @@ describe('Env Config', () => {
295
281
296
282
try {
297
283
const browser = await webdriver ( appPort , '/global' )
298
- expect ( await browser . elementByCss ( 'p' ) . text ( ) ) . toBe ( 'another' )
284
+ expect (
285
+ await browser . waitForElementByCss ( '#global-value' ) . text ( )
286
+ ) . toBe ( 'another' )
299
287
300
288
let outputIdx = output . length
301
289
@@ -313,7 +301,10 @@ describe('Env Config', () => {
313
301
) . toBe ( 1 )
314
302
expect ( output . substring ( outputIdx ) ) . not . toContain ( '.env.local' )
315
303
316
- await check ( ( ) => browser . elementByCss ( 'p' ) . text ( ) , 'replaced' )
304
+ await check (
305
+ ( ) => browser . waitForElementByCss ( '#global-value' ) . text ( ) ,
306
+ 'replaced'
307
+ )
317
308
318
309
outputIdx = output . length
319
310
@@ -328,7 +319,10 @@ describe('Env Config', () => {
328
319
) . toBe ( 1 )
329
320
expect ( output . substring ( outputIdx ) ) . toContain ( '.env.local' )
330
321
331
- await check ( ( ) => browser . elementByCss ( 'p' ) . text ( ) , 'overridden' )
322
+ await check (
323
+ ( ) => browser . waitForElementByCss ( '#global-value' ) . text ( ) ,
324
+ 'overridden'
325
+ )
332
326
333
327
outputIdx = output . length
334
328
0 commit comments