@@ -2,6 +2,7 @@ import { nextTestSetup } from 'e2e-utils'
22import { getBrowserBodyText , retry } from 'next-test-utils'
33import fs from 'fs-extra'
44import path from 'path'
5+ import { type Playwright } from 'next-webdriver'
56
67const READ_ONLY_PERMISSIONS = 0o444
78const READ_WRITE_PERMISSIONS = 0o644
@@ -71,39 +72,39 @@ describe('Read-only source HMR', () => {
7172 }
7273
7374 it ( 'should detect changes to a page' , async ( ) => {
74- let browser
75+ let browser : Playwright
7576
7677 try {
7778 browser = await next . browser ( '/hello' )
7879 await retry ( async ( ) =>
79- expect ( await getBrowserBodyText ( browser ) ) . toBe ( 'Hello World' )
80+ expect ( await getBrowserBodyText ( browser ) ) . toContain ( 'Hello World' )
8081 )
8182
8283 await patchFileReadOnly (
8384 pageHello ,
8485 ( content ) => content . replace ( 'Hello World' , 'COOL page' ) ,
8586 async ( ) => {
8687 await retry ( async ( ) =>
87- expect ( await getBrowserBodyText ( browser ) ) . toBe ( 'COOL page' )
88+ expect ( await getBrowserBodyText ( browser ) ) . toContain ( 'COOL page' )
8889 )
8990 }
9091 )
9192
9293 await retry ( async ( ) =>
93- expect ( await getBrowserBodyText ( browser ) ) . toBe ( 'Hello World' )
94+ expect ( await getBrowserBodyText ( browser ) ) . toContain ( 'Hello World' )
9495 )
9596 } finally {
9697 await browser ?. close ( )
9798 }
9899 } )
99100
100101 it ( 'should handle page deletion and subsequent recreation' , async ( ) => {
101- let browser
102+ let browser : Playwright
102103
103104 try {
104105 browser = await next . browser ( '/hello' )
105106 await retry ( async ( ) =>
106- expect ( await getBrowserBodyText ( browser ) ) . toBe ( 'Hello World' )
107+ expect ( await getBrowserBodyText ( browser ) ) . toContain ( 'Hello World' )
107108 )
108109
109110 await patchFileReadOnly (
@@ -118,16 +119,20 @@ describe('Read-only source HMR', () => {
118119 }
119120 )
120121
121- await retry ( async ( ) =>
122- expect ( await getBrowserBodyText ( browser ) ) . toBe ( 'Hello World' )
123- )
122+ await retry ( async ( ) => {
123+ if ( ! process . env . IS_TURBOPACK_TEST ) {
124+ // webpack doesn't automatically refresh the page when a page is added?
125+ await browser . refresh ( )
126+ }
127+ expect ( await getBrowserBodyText ( browser ) ) . toContain ( 'Hello World' )
128+ } )
124129 } finally {
125130 await browser ?. close ( )
126131 }
127132 } )
128133
129134 it ( 'should detect a new page' , async ( ) => {
130- let browser
135+ let browser : Playwright
131136
132137 try {
133138 await patchFileReadOnly (
@@ -140,7 +145,7 @@ describe('Read-only source HMR', () => {
140145 async ( ) => {
141146 browser = await next . browser ( '/new' )
142147 await retry ( async ( ) =>
143- expect ( await getBrowserBodyText ( browser ) ) . toBe ( 'New page' )
148+ expect ( await getBrowserBodyText ( browser ) ) . toContain ( 'New page' )
144149 )
145150 }
146151 )
0 commit comments