1
1
"use strict" ;
2
2
3
3
const webpack = require ( "webpack" ) ;
4
- const { describe , test, beforeEach , afterEach } = require ( "@playwright/ test" ) ;
4
+ const { test } = require ( "../helpers/playwright- test" ) ;
5
5
const { expect } = require ( "../helpers/playwright-custom-expects" ) ;
6
6
const Server = require ( "../../lib/Server" ) ;
7
7
const config = require ( "../fixtures/client-config/webpack.config" ) ;
8
8
const multiConfig = require ( "../fixtures/multi-public-path-config/webpack.config" ) ;
9
9
const port = require ( "../ports-map" ) . routes ;
10
10
11
- describe ( "Built in routes" , ( ) => {
12
- describe ( "with simple config" , ( ) => {
11
+ test . describe ( "Built in routes" , ( ) => {
12
+ test . describe ( "with simple config" , ( ) => {
13
13
let compiler ;
14
14
let server ;
15
15
let pageErrors ;
16
16
let consoleMessages ;
17
17
18
- beforeEach ( async ( ) => {
18
+ test . beforeEach ( async ( ) => {
19
19
compiler = webpack ( config ) ;
20
20
server = new Server ( { port } , compiler ) ;
21
21
@@ -25,7 +25,7 @@ describe("Built in routes", () => {
25
25
consoleMessages = [ ] ;
26
26
} ) ;
27
27
28
- afterEach ( async ( ) => {
28
+ test . afterEach ( async ( ) => {
29
29
await server . stop ( ) ;
30
30
} ) ;
31
31
@@ -45,17 +45,17 @@ describe("Built in routes", () => {
45
45
} ,
46
46
) ;
47
47
48
- expect (
49
- response . headers ( ) [ "content-type" ]
50
- ) . toMatchSnapshotWithArray ( ) ;
48
+ expect ( response . headers ( ) [ "content-type" ] ) . toMatchSnapshotWithArray (
49
+ " response headers" ,
50
+ ) ;
51
51
52
- expect ( response . status ( ) ) . toMatchSnapshotWithArray ( ) ;
52
+ expect ( response . status ( ) ) . toMatchSnapshotWithArray ( "response status" ) ;
53
53
54
54
expect (
55
- consoleMessages . map ( ( message ) => message . text ( ) )
56
- ) . toMatchSnapshotWithArray ( ) ;
55
+ consoleMessages . map ( ( message ) => message . text ( ) ) ,
56
+ ) . toMatchSnapshotWithArray ( "console messages" ) ;
57
57
58
- expect ( pageErrors ) . toMatchSnapshotWithArray ( ) ;
58
+ expect ( pageErrors ) . toMatchSnapshotWithArray ( "page errors" ) ;
59
59
} ) ;
60
60
61
61
test ( "should handles HEAD request to sockjs bundle" , async ( { page } ) => {
@@ -65,11 +65,11 @@ describe("Built in routes", () => {
65
65
} )
66
66
. on ( "pageerror" , ( error ) => {
67
67
pageErrors . push ( error ) ;
68
- } )
68
+ } ) ;
69
69
70
70
await page . route ( "**/*" , ( route ) => {
71
- route . continue ( { method : "HEAD" } )
72
- } )
71
+ route . continue ( { method : "HEAD" } ) ;
72
+ } ) ;
73
73
74
74
const response = await page . goto (
75
75
`http://127.0.0.1:${ port } /__webpack_dev_server__/sockjs.bundle.js` ,
@@ -78,17 +78,17 @@ describe("Built in routes", () => {
78
78
} ,
79
79
) ;
80
80
81
- expect (
82
- response . headers ( ) [ "content-type" ]
83
- ) . toMatchSnapshotWithArray ( ) ;
81
+ expect ( response . headers ( ) [ "content-type" ] ) . toMatchSnapshotWithArray (
82
+ " response headers" ,
83
+ ) ;
84
84
85
- expect ( response . status ( ) ) . toMatchSnapshotWithArray ( ) ;
85
+ expect ( response . status ( ) ) . toMatchSnapshotWithArray ( "response status" ) ;
86
86
87
87
expect (
88
- consoleMessages . map ( ( message ) => message . text ( ) )
89
- ) . toMatchSnapshotWithArray ( ) ;
88
+ consoleMessages . map ( ( message ) => message . text ( ) ) ,
89
+ ) . toMatchSnapshotWithArray ( "console messages" ) ;
90
90
91
- expect ( pageErrors ) . toMatchSnapshotWithArray ( ) ;
91
+ expect ( pageErrors ) . toMatchSnapshotWithArray ( "page errors" ) ;
92
92
} ) ;
93
93
94
94
test ( "should handle GET request to invalidate endpoint" , async ( {
@@ -109,17 +109,15 @@ describe("Built in routes", () => {
109
109
} ,
110
110
) ;
111
111
112
- expect ( response . headers ( ) [ "content-type" ] ) . not . toEqual (
113
- "text/html" ,
114
- ) ;
112
+ expect ( response . headers ( ) [ "content-type" ] ) . not . toEqual ( "text/html" ) ;
115
113
116
- expect ( response . status ( ) ) . toMatchSnapshotWithArray ( ) ;
114
+ expect ( response . status ( ) ) . toMatchSnapshotWithArray ( "response status" ) ;
117
115
118
116
expect (
119
- consoleMessages . map ( ( message ) => message . text ( ) )
120
- ) . toMatchSnapshotWithArray ( ) ;
117
+ consoleMessages . map ( ( message ) => message . text ( ) ) ,
118
+ ) . toMatchSnapshotWithArray ( "console messages" ) ;
121
119
122
- expect ( pageErrors ) . toMatchSnapshotWithArray ( ) ;
120
+ expect ( pageErrors ) . toMatchSnapshotWithArray ( "page errors" ) ;
123
121
} ) ;
124
122
125
123
test ( "should handle GET request to directory index and list all middleware directories" , async ( {
@@ -140,19 +138,19 @@ describe("Built in routes", () => {
140
138
} ,
141
139
) ;
142
140
143
- expect (
144
- response . headers ( ) [ "content-type" ]
145
- ) . toMatchSnapshotWithArray ( ) ;
141
+ expect ( response . headers ( ) [ "content-type" ] ) . toMatchSnapshotWithArray (
142
+ " response headers" ,
143
+ ) ;
146
144
147
- expect ( response . status ( ) ) . toMatchSnapshotWithArray ( ) ;
145
+ expect ( response . status ( ) ) . toMatchSnapshotWithArray ( "response status" ) ;
148
146
149
- expect ( await response . text ( ) ) . toMatchSnapshotWithArray ( ) ;
147
+ expect ( await response . text ( ) ) . toMatchSnapshotWithArray ( "response text" ) ;
150
148
151
149
expect (
152
- consoleMessages . map ( ( message ) => message . text ( ) )
153
- ) . toMatchSnapshotWithArray ( ) ;
150
+ consoleMessages . map ( ( message ) => message . text ( ) ) ,
151
+ ) . toMatchSnapshotWithArray ( "console messages" ) ;
154
152
155
- expect ( pageErrors ) . toMatchSnapshotWithArray ( ) ;
153
+ expect ( pageErrors ) . toMatchSnapshotWithArray ( "page errors" ) ;
156
154
} ) ;
157
155
158
156
test ( "should handle HEAD request to directory index" , async ( { page } ) => {
@@ -162,11 +160,11 @@ describe("Built in routes", () => {
162
160
} )
163
161
. on ( "pageerror" , ( error ) => {
164
162
pageErrors . push ( error ) ;
165
- } )
163
+ } ) ;
166
164
167
165
await page . route ( "**/*" , ( route ) => {
168
- route . continue ( { method : "HEAD" } )
169
- } )
166
+ route . continue ( { method : "HEAD" } ) ;
167
+ } ) ;
170
168
171
169
const response = await page . goto (
172
170
`http://127.0.0.1:${ port } /webpack-dev-server/` ,
@@ -175,19 +173,19 @@ describe("Built in routes", () => {
175
173
} ,
176
174
) ;
177
175
178
- expect (
179
- response . headers ( ) [ "content-type" ]
180
- ) . toMatchSnapshotWithArray ( ) ;
176
+ expect ( response . headers ( ) [ "content-type" ] ) . toMatchSnapshotWithArray (
177
+ " response headers" ,
178
+ ) ;
181
179
182
- expect ( response . status ( ) ) . toMatchSnapshotWithArray ( ) ;
180
+ expect ( response . status ( ) ) . toMatchSnapshotWithArray ( "response status" ) ;
183
181
184
- expect ( await response . text ( ) ) . toMatchSnapshotWithArray ( ) ;
182
+ expect ( await response . text ( ) ) . toMatchSnapshotWithArray ( "response text" ) ;
185
183
186
184
expect (
187
- consoleMessages . map ( ( message ) => message . text ( ) )
188
- ) . toMatchSnapshotWithArray ( ) ;
185
+ consoleMessages . map ( ( message ) => message . text ( ) ) ,
186
+ ) . toMatchSnapshotWithArray ( "console messages" ) ;
189
187
190
- expect ( pageErrors ) . toMatchSnapshotWithArray ( ) ;
188
+ expect ( pageErrors ) . toMatchSnapshotWithArray ( "page errors" ) ;
191
189
} ) ;
192
190
193
191
test ( "should handle GET request to magic async chunk" , async ( { page } ) => {
@@ -203,15 +201,15 @@ describe("Built in routes", () => {
203
201
waitUntil : "networkidle0" ,
204
202
} ) ;
205
203
206
- expect (
207
- response . headers ( ) [ "content-type" ]
208
- ) . toMatchSnapshotWithArray ( ) ;
204
+ expect ( response . headers ( ) [ "content-type" ] ) . toMatchSnapshotWithArray (
205
+ " response headers" ,
206
+ ) ;
209
207
210
- expect ( response . status ( ) ) . toMatchSnapshotWithArray ( ) ;
208
+ expect ( response . status ( ) ) . toMatchSnapshotWithArray ( "response status" ) ;
211
209
212
210
expect (
213
- consoleMessages . map ( ( message ) => message . text ( ) )
214
- ) . toMatchSnapshotWithArray ( ) ;
211
+ consoleMessages . map ( ( message ) => message . text ( ) ) ,
212
+ ) . toMatchSnapshotWithArray ( "console messages" ) ;
215
213
} ) ;
216
214
217
215
// FIXME: improve it
@@ -224,35 +222,35 @@ describe("Built in routes", () => {
224
222
} )
225
223
. on ( "pageerror" , ( error ) => {
226
224
pageErrors . push ( error ) ;
227
- } )
225
+ } ) ;
228
226
229
227
await page . route ( "**/*" , ( route ) => {
230
- route . continue ( { method : "HEAD" } )
231
- } )
228
+ route . continue ( { method : "HEAD" } ) ;
229
+ } ) ;
232
230
233
231
const response = await page . goto ( `http://127.0.0.1:${ port } /main.js` , {
234
232
waitUntil : "networkidle0" ,
235
233
} ) ;
236
234
237
- expect (
238
- response . headers ( ) [ "content-type" ]
239
- ) . toMatchSnapshotWithArray ( ) ;
235
+ expect ( response . headers ( ) [ "content-type" ] ) . toMatchSnapshotWithArray (
236
+ " response headers" ,
237
+ ) ;
240
238
241
- expect ( response . status ( ) ) . toMatchSnapshotWithArray ( ) ;
239
+ expect ( response . status ( ) ) . toMatchSnapshotWithArray ( "response status" ) ;
242
240
243
241
expect (
244
- consoleMessages . map ( ( message ) => message . text ( ) )
245
- ) . toMatchSnapshotWithArray ( ) ;
242
+ consoleMessages . map ( ( message ) => message . text ( ) ) ,
243
+ ) . toMatchSnapshotWithArray ( "console messages" ) ;
246
244
} ) ;
247
245
} ) ;
248
246
249
- describe ( "with multi config" , ( ) => {
247
+ test . describe ( "with multi config" , ( ) => {
250
248
let compiler ;
251
249
let server ;
252
250
let pageErrors ;
253
251
let consoleMessages ;
254
252
255
- beforeEach ( async ( ) => {
253
+ test . beforeEach ( async ( ) => {
256
254
compiler = webpack ( multiConfig ) ;
257
255
server = new Server ( { port } , compiler ) ;
258
256
@@ -262,7 +260,7 @@ describe("Built in routes", () => {
262
260
consoleMessages = [ ] ;
263
261
} ) ;
264
262
265
- afterEach ( async ( ) => {
263
+ test . afterEach ( async ( ) => {
266
264
await server . stop ( ) ;
267
265
} ) ;
268
266
@@ -284,19 +282,19 @@ describe("Built in routes", () => {
284
282
} ,
285
283
) ;
286
284
287
- expect (
288
- response . headers ( ) [ "content-type" ]
289
- ) . toMatchSnapshotWithArray ( ) ;
285
+ expect ( response . headers ( ) [ "content-type" ] ) . toMatchSnapshotWithArray (
286
+ " response headers" ,
287
+ ) ;
290
288
291
- expect ( response . status ( ) ) . toMatchSnapshotWithArray ( ) ;
289
+ expect ( response . status ( ) ) . toMatchSnapshotWithArray ( "response status" ) ;
292
290
293
- expect ( await response . text ( ) ) . toMatchSnapshotWithArray ( ) ;
291
+ expect ( await response . text ( ) ) . toMatchSnapshotWithArray ( "response text" ) ;
294
292
295
293
expect (
296
- consoleMessages . map ( ( message ) => message . text ( ) )
297
- ) . toMatchSnapshotWithArray ( ) ;
294
+ consoleMessages . map ( ( message ) => message . text ( ) ) ,
295
+ ) . toMatchSnapshotWithArray ( "console messages" ) ;
298
296
299
- expect ( pageErrors ) . toMatchSnapshotWithArray ( ) ;
297
+ expect ( pageErrors ) . toMatchSnapshotWithArray ( "page errors" ) ;
300
298
} ) ;
301
299
} ) ;
302
300
} ) ;
0 commit comments