@@ -81,59 +81,59 @@ test('build w/ multi page', async () => {
8181
8282 const assertSharedAssets = file => {
8383 // should split and preload vendor chunk
84- expect ( file ) . toMatch ( / < l i n k [ ^ > ] + j s \/ c h u n k - v e n d o r s [ ^ > ] + \. j s r e l = p r e l o a d > / )
84+ expect ( file ) . toMatch ( / < l i n k [ ^ > ] * j s \/ c h u n k - v e n d o r s [ ^ > ] * \. j s r e l = p r e l o a d > / )
8585 // should split and preload common js and css
86- expect ( file ) . toMatch ( / < l i n k [ ^ > ] + j s \/ c h u n k - c o m m o n [ ^ > ] + \. j s r e l = p r e l o a d > / )
87- expect ( file ) . toMatch ( / < l i n k [ ^ > ] + c h u n k - c o m m o n [ ^ > ] + \. c s s r e l = p r e l o a d > / )
86+ expect ( file ) . toMatch ( / < l i n k [ ^ > ] * j s \/ c h u n k - c o m m o n [ ^ > ] * \. j s r e l = p r e l o a d > / )
87+ expect ( file ) . toMatch ( / < l i n k [ ^ > ] * c h u n k - c o m m o n [ ^ > ] * \. c s s r e l = p r e l o a d > / )
8888 // should load common css
8989 expect ( file ) . toMatch ( / < l i n k h r e f = \/ c s s \/ c h u n k - c o m m o n \. \w + \. c s s r e l = s t y l e s h e e t > / )
9090 // should load common js
91- expect ( file ) . toMatch ( / < s c r i p t [ ^ > ] + s r c = \/ j s \/ c h u n k - v e n d o r s \. \w + \. j s > / )
92- expect ( file ) . toMatch ( / < s c r i p t [ ^ > ] + s r c = \/ j s \/ c h u n k - c o m m o n \. \w + \. j s > / )
91+ expect ( file ) . toMatch ( / < s c r i p t [ ^ > ] * s r c = \/ j s \/ c h u n k - v e n d o r s \. \w + \. j s > / )
92+ expect ( file ) . toMatch ( / < s c r i p t [ ^ > ] * s r c = \/ j s \/ c h u n k - c o m m o n \. \w + \. j s > / )
9393 }
9494
9595 const index = await project . read ( 'dist/index.html' )
9696 assertSharedAssets ( index )
9797 // should preload correct page file
98- expect ( index ) . toMatch ( / < l i n k [ ^ > ] + j s \/ i n d e x [ ^ > ] + \. j s r e l = p r e l o a d > / )
99- expect ( index ) . not . toMatch ( / < l i n k [ ^ > ] + j s \/ f o o [ ^ > ] + \. j s r e l = p r e l o a d > / )
100- expect ( index ) . not . toMatch ( / < l i n k [ ^ > ] + j s \/ b a r [ ^ > ] + \. j s r e l = p r e l o a d > / )
98+ expect ( index ) . toMatch ( / < l i n k [ ^ > ] * j s \/ i n d e x [ ^ > ] * \. j s r e l = p r e l o a d > / )
99+ expect ( index ) . not . toMatch ( / < l i n k [ ^ > ] * j s \/ f o o [ ^ > ] * \. j s r e l = p r e l o a d > / )
100+ expect ( index ) . not . toMatch ( / < l i n k [ ^ > ] * j s \/ b a r [ ^ > ] * \. j s r e l = p r e l o a d > / )
101101 // should prefetch async chunk js and css
102- expect ( index ) . toMatch ( / < l i n k [ ^ > ] + c s s \/ 0 \. \w + \. c s s r e l = p r e f e t c h > / )
103- expect ( index ) . toMatch ( / < l i n k [ ^ > ] + j s \/ 0 \. \w + \. j s r e l = p r e f e t c h > / )
102+ expect ( index ) . toMatch ( / < l i n k [ ^ > ] * c s s \/ 0 \. \w + \. c s s r e l = p r e f e t c h > / )
103+ expect ( index ) . toMatch ( / < l i n k [ ^ > ] * j s \/ 0 \. \w + \. j s r e l = p r e f e t c h > / )
104104 // should load correct page js
105- expect ( index ) . toMatch ( / < s c r i p t [ ^ > ] + s r c = \/ j s \/ i n d e x \. \w + \. j s > / )
106- expect ( index ) . not . toMatch ( / < s c r i p t [ ^ > ] + s r c = \/ j s \/ f o o \. \w + \. j s > / )
107- expect ( index ) . not . toMatch ( / < s c r i p t [ ^ > ] + s r c = \/ j s \/ b a r \. \w + \. j s > / )
105+ expect ( index ) . toMatch ( / < s c r i p t [ ^ > ] * s r c = \/ j s \/ i n d e x \. \w + \. j s > / )
106+ expect ( index ) . not . toMatch ( / < s c r i p t [ ^ > ] * s r c = \/ j s \/ f o o \. \w + \. j s > / )
107+ expect ( index ) . not . toMatch ( / < s c r i p t [ ^ > ] * s r c = \/ j s \/ b a r \. \w + \. j s > / )
108108
109109 const foo = await project . read ( 'dist/foo.html' )
110110 assertSharedAssets ( foo )
111111 // should preload correct page file
112- expect ( foo ) . not . toMatch ( / < l i n k [ ^ > ] + j s \/ i n d e x [ ^ > ] + \. j s r e l = p r e l o a d > / )
113- expect ( foo ) . toMatch ( / < l i n k [ ^ > ] + j s \/ f o o [ ^ > ] + \. j s r e l = p r e l o a d > / )
114- expect ( foo ) . not . toMatch ( / < l i n k [ ^ > ] + j s \/ b a r [ ^ > ] + \. j s r e l = p r e l o a d > / )
112+ expect ( foo ) . not . toMatch ( / < l i n k [ ^ > ] * j s \/ i n d e x [ ^ > ] * \. j s r e l = p r e l o a d > / )
113+ expect ( foo ) . toMatch ( / < l i n k [ ^ > ] * j s \/ f o o [ ^ > ] * \. j s r e l = p r e l o a d > / )
114+ expect ( foo ) . not . toMatch ( / < l i n k [ ^ > ] * j s \/ b a r [ ^ > ] * \. j s r e l = p r e l o a d > / )
115115 // should not prefetch async chunk js and css because it's not used by
116116 // this entry
117- expect ( foo ) . not . toMatch ( / < l i n k [ ^ > ] + c s s \/ 0 \. \w + \. c s s r e l = p r e f e t c h > / )
118- expect ( foo ) . not . toMatch ( / < l i n k [ ^ > ] + j s \/ 0 \. \w + \. j s r e l = p r e f e t c h > / )
117+ expect ( foo ) . not . toMatch ( / < l i n k [ ^ > ] * c s s \/ 0 \. \w + \. c s s r e l = p r e f e t c h > / )
118+ expect ( foo ) . not . toMatch ( / < l i n k [ ^ > ] * j s \/ 0 \. \w + \. j s r e l = p r e f e t c h > / )
119119 // should load correct page js
120- expect ( foo ) . not . toMatch ( / < s c r i p t [ ^ > ] + s r c = \/ j s \/ i n d e x \. \w + \. j s > / )
121- expect ( foo ) . toMatch ( / < s c r i p t [ ^ > ] + s r c = \/ j s \/ f o o \. \w + \. j s > / )
122- expect ( foo ) . not . toMatch ( / < s c r i p t [ ^ > ] + s r c = \/ j s \/ b a r \. \w + \. j s > / )
120+ expect ( foo ) . not . toMatch ( / < s c r i p t [ ^ > ] * s r c = \/ j s \/ i n d e x \. \w + \. j s > / )
121+ expect ( foo ) . toMatch ( / < s c r i p t [ ^ > ] * s r c = \/ j s \/ f o o \. \w + \. j s > / )
122+ expect ( foo ) . not . toMatch ( / < s c r i p t [ ^ > ] * s r c = \/ j s \/ b a r \. \w + \. j s > / )
123123
124124 const bar = await project . read ( 'dist/bar.html' )
125125 assertSharedAssets ( bar )
126126 // should preload correct page file
127- expect ( bar ) . not . toMatch ( / < l i n k [ ^ > ] + j s \/ i n d e x [ ^ > ] + \. j s r e l = p r e l o a d > / )
128- expect ( bar ) . not . toMatch ( / < l i n k [ ^ > ] + j s \/ f o o [ ^ > ] + \. j s r e l = p r e l o a d > / )
129- expect ( bar ) . toMatch ( / < l i n k [ ^ > ] + j s \/ b a r [ ^ > ] + \. j s r e l = p r e l o a d > / )
127+ expect ( bar ) . not . toMatch ( / < l i n k [ ^ > ] * j s \/ i n d e x [ ^ > ] * \. j s r e l = p r e l o a d > / )
128+ expect ( bar ) . not . toMatch ( / < l i n k [ ^ > ] * j s \/ f o o [ ^ > ] * \. j s r e l = p r e l o a d > / )
129+ expect ( bar ) . toMatch ( / < l i n k [ ^ > ] * j s \/ b a r [ ^ > ] * \. j s r e l = p r e l o a d > / )
130130 // should prefetch async chunk js and css
131- expect ( bar ) . toMatch ( / < l i n k [ ^ > ] + c s s \/ 0 \. \w + \. c s s r e l = p r e f e t c h > / )
132- expect ( bar ) . toMatch ( / < l i n k [ ^ > ] + j s \/ 0 \. \w + \. j s r e l = p r e f e t c h > / )
131+ expect ( bar ) . toMatch ( / < l i n k [ ^ > ] * c s s \/ 0 \. \w + \. c s s r e l = p r e f e t c h > / )
132+ expect ( bar ) . toMatch ( / < l i n k [ ^ > ] * j s \/ 0 \. \w + \. j s r e l = p r e f e t c h > / )
133133 // should load correct page js
134- expect ( bar ) . not . toMatch ( / < s c r i p t [ ^ > ] + s r c = \/ j s \/ i n d e x \. \w + \. j s > / )
135- expect ( bar ) . not . toMatch ( / < s c r i p t [ ^ > ] + s r c = \/ j s \/ f o o \. \w + \. j s > / )
136- expect ( bar ) . toMatch ( / < s c r i p t [ ^ > ] + s r c = \/ j s \/ b a r \. \w + \. j s > / )
134+ expect ( bar ) . not . toMatch ( / < s c r i p t [ ^ > ] * s r c = \/ j s \/ i n d e x \. \w + \. j s > / )
135+ expect ( bar ) . not . toMatch ( / < s c r i p t [ ^ > ] * s r c = \/ j s \/ f o o \. \w + \. j s > / )
136+ expect ( bar ) . toMatch ( / < s c r i p t [ ^ > ] * s r c = \/ j s \/ b a r \. \w + \. j s > / )
137137
138138 // assert pages work
139139 const port = await portfinder . getPortPromise ( )
@@ -165,6 +165,10 @@ test('build w/ multi page', async () => {
165165} )
166166
167167afterAll ( async ( ) => {
168- await browser . close ( )
169- server . close ( )
168+ if ( browser ) {
169+ await browser . close ( )
170+ }
171+ if ( server ) {
172+ server . close ( )
173+ }
170174} )
0 commit comments