@@ -73,95 +73,106 @@ describe('persistent-caching', () => {
7373 }
7474 } )
7575
76- it ( 'should allow to change files while stopped' , async ( ) => {
77- {
78- const browser = await next . browser ( '/' )
79- expect ( await browser . elementByCss ( 'p' ) . text ( ) ) . toBe ( 'hello world' )
80- await browser . close ( )
81- }
82- {
83- const browser = await next . browser ( '/client' )
84- expect ( await browser . elementByCss ( 'p' ) . text ( ) ) . toBe ( 'hello world' )
85- await browser . close ( )
86- }
87- {
88- const browser = await next . browser ( '/pages' )
89- expect ( await browser . elementByCss ( 'p' ) . text ( ) ) . toBe ( 'hello world' )
90- await browser . close ( )
91- }
92- {
93- const browser = await next . browser ( '/remove-me' )
94- expect ( await browser . elementByCss ( 'p' ) . text ( ) ) . toBe ( 'hello world' )
95- await browser . close ( )
96- }
76+ it . each ( [ 1 , 2 , 3 ] ) (
77+ 'should allow to change files while stopped (run %d)' ,
78+ async ( _i ) => {
79+ async function checkInitial ( ) {
80+ {
81+ const browser = await next . browser ( '/' )
82+ expect ( await browser . elementByCss ( 'p' ) . text ( ) ) . toBe ( 'hello world' )
83+ await browser . close ( )
84+ }
85+ {
86+ const browser = await next . browser ( '/client' )
87+ expect ( await browser . elementByCss ( 'p' ) . text ( ) ) . toBe ( 'hello world' )
88+ await browser . close ( )
89+ }
90+ {
91+ const browser = await next . browser ( '/pages' )
92+ expect ( await browser . elementByCss ( 'p' ) . text ( ) ) . toBe ( 'hello world' )
93+ await browser . close ( )
94+ }
95+ {
96+ const browser = await next . browser ( '/remove-me' )
97+ expect ( await browser . elementByCss ( 'p' ) . text ( ) ) . toBe ( 'hello world' )
98+ await browser . close ( )
99+ }
100+ }
97101
98- await stop ( )
102+ await checkInitial ( )
99103
100- async function checkChanges ( ) {
101- {
102- const browser = await next . browser ( '/' )
103- expect ( await browser . elementByCss ( 'p' ) . text ( ) ) . toBe (
104- 'hello persistent caching'
105- )
106- await browser . close ( )
107- }
108- {
109- const browser = await next . browser ( '/client' )
110- expect ( await browser . elementByCss ( 'p' ) . text ( ) ) . toBe (
111- 'hello persistent caching'
112- )
113- await browser . close ( )
114- }
115- {
116- const browser = await next . browser ( '/pages' )
117- expect ( await browser . elementByCss ( 'p' ) . text ( ) ) . toBe (
118- 'hello persistent caching'
119- )
120- await browser . close ( )
121- }
104+ await stop ( )
122105
123- {
124- const browser = await next . browser ( '/add-me' )
125- expect ( await browser . elementByCss ( 'p' ) . text ( ) ) . toBe ( 'hello world' )
126- await browser . close ( )
106+ async function checkChanges ( ) {
107+ {
108+ const browser = await next . browser ( '/' )
109+ expect ( await browser . elementByCss ( 'p' ) . text ( ) ) . toBe (
110+ 'hello persistent caching'
111+ )
112+ await browser . close ( )
113+ }
114+ {
115+ const browser = await next . browser ( '/client' )
116+ expect ( await browser . elementByCss ( 'p' ) . text ( ) ) . toBe (
117+ 'hello persistent caching'
118+ )
119+ await browser . close ( )
120+ }
121+ {
122+ const browser = await next . browser ( '/pages' )
123+ expect ( await browser . elementByCss ( 'p' ) . text ( ) ) . toBe (
124+ 'hello persistent caching'
125+ )
126+ await browser . close ( )
127+ }
128+ {
129+ const browser = await next . browser ( '/add-me' )
130+ expect ( await browser . elementByCss ( 'p' ) . text ( ) ) . toBe ( 'hello world' )
131+ await browser . close ( )
132+ }
127133 }
128- }
129134
130- await next . patchFile (
131- 'pages/pages.tsx' ,
132- ( content ) => {
133- return content . replace ( 'hello world' , 'hello persistent caching' )
134- } ,
135- async ( ) => {
136- await next . patchFile (
137- 'app/page.tsx' ,
138- ( content ) => {
139- return content . replace ( 'hello world' , 'hello persistent caching' )
140- } ,
141- async ( ) => {
142- await next . patchFile (
143- 'app/client/page.tsx' ,
144- ( content ) => {
145- return content . replace (
146- 'hello world' ,
147- 'hello persistent caching'
148- )
149- } ,
150- async ( ) => {
151- await next . renameFolder ( 'app/remove-me' , 'app/add-me' )
152- try {
153- await start ( )
154- await checkChanges ( )
155- await stop ( )
156- } finally {
157- await next . renameFolder ( 'app/add-me' , 'app/remove-me' )
135+ await next . patchFile (
136+ 'pages/pages.tsx' ,
137+ ( content ) => {
138+ return content . replace ( 'hello world' , 'hello persistent caching' )
139+ } ,
140+ async ( ) => {
141+ await next . patchFile (
142+ 'app/page.tsx' ,
143+ ( content ) => {
144+ return content . replace ( 'hello world' , 'hello persistent caching' )
145+ } ,
146+ async ( ) => {
147+ await next . patchFile (
148+ 'app/client/page.tsx' ,
149+ ( content ) => {
150+ return content . replace (
151+ 'hello world' ,
152+ 'hello persistent caching'
153+ )
154+ } ,
155+ async ( ) => {
156+ await next . renameFolder ( 'app/remove-me' , 'app/add-me' )
157+ try {
158+ await start ( )
159+ await checkChanges ( )
160+ // Some no-op change builds
161+ for ( let i = 0 ; i < 2 ; i ++ ) {
162+ await restartCycle ( )
163+ await checkChanges ( )
164+ }
165+ await stop ( )
166+ } finally {
167+ await next . renameFolder ( 'app/add-me' , 'app/remove-me' )
168+ }
158169 }
159- }
160- )
161- }
162- )
163- }
164- )
165- await start ( )
166- } )
170+ )
171+ }
172+ )
173+ }
174+ )
175+ await start ( )
176+ }
177+ )
167178} )
0 commit comments