@@ -81,59 +81,59 @@ test('build w/ multi page', async () => {
81
81
82
82
const assertSharedAssets = file => {
83
83
// 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 > / )
85
85
// 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 > / )
88
88
// should load common css
89
89
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 > / )
90
90
// 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 > / )
93
93
}
94
94
95
95
const index = await project . read ( 'dist/index.html' )
96
96
assertSharedAssets ( index )
97
97
// 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 > / )
101
101
// 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 > / )
104
104
// 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 > / )
108
108
109
109
const foo = await project . read ( 'dist/foo.html' )
110
110
assertSharedAssets ( foo )
111
111
// 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 > / )
115
115
// should not prefetch async chunk js and css because it's not used by
116
116
// 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 > / )
119
119
// 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 > / )
123
123
124
124
const bar = await project . read ( 'dist/bar.html' )
125
125
assertSharedAssets ( bar )
126
126
// 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 > / )
130
130
// 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 > / )
133
133
// 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 > / )
137
137
138
138
// assert pages work
139
139
const port = await portfinder . getPortPromise ( )
@@ -165,6 +165,10 @@ test('build w/ multi page', async () => {
165
165
} )
166
166
167
167
afterAll ( async ( ) => {
168
- await browser . close ( )
169
- server . close ( )
168
+ if ( browser ) {
169
+ await browser . close ( )
170
+ }
171
+ if ( server ) {
172
+ server . close ( )
173
+ }
170
174
} )
0 commit comments