2
2
3
3
const os = require ( "os" ) ;
4
4
const webpack = require ( "webpack" ) ;
5
- const { describe, test, beforeEach, beforeAll, afterEach } = require ( "@playwright/test" ) ;
6
5
const sinon = require ( "sinon" ) ;
7
6
const bonjourService = require ( "bonjour-service" ) ;
7
+ const { test } = require ( "../helpers/playwright-test" ) ;
8
8
const { expect } = require ( "../helpers/playwright-custom-expects" ) ;
9
9
const Server = require ( "../../lib/Server" ) ;
10
10
const config = require ( "../fixtures/simple-config/webpack.config" ) ;
11
11
const port = require ( "../ports-map" ) . bonjour ;
12
12
13
- describe ( "bonjour option" , { tag : "@flaky" } , ( ) => {
13
+ test . describe ( "bonjour option" , { tag : "@flaky" } , ( ) => {
14
14
let mockPublish ;
15
15
let mockUnpublishAll ;
16
16
let mockDestroy ;
17
17
18
- beforeAll ( ( ) => {
18
+ test . beforeAll ( ( ) => {
19
19
mockPublish = sinon . stub ( ) ;
20
20
mockUnpublishAll = sinon . stub ( ) . callsFake ( ( callback ) => {
21
21
callback ( ) ;
22
22
} ) ;
23
23
mockDestroy = sinon . stub ( ) ;
24
24
25
- sinon . stub ( bonjourService , ' Bonjour' ) . returns ( {
25
+ sinon . stub ( bonjourService , " Bonjour" ) . returns ( {
26
26
publish : mockPublish ,
27
27
unpublishAll : mockUnpublishAll ,
28
28
destroy : mockDestroy ,
29
- } )
29
+ } ) ;
30
30
} ) ;
31
31
32
- afterEach ( ( ) => {
32
+ test . afterEach ( ( ) => {
33
33
mockPublish . resetHistory ( ) ;
34
34
mockUnpublishAll . resetHistory ( ) ;
35
35
mockDestroy . resetHistory ( ) ;
36
- } )
36
+ } ) ;
37
37
38
- describe ( "as true" , ( ) => {
38
+ test . describe ( "as true" , ( ) => {
39
39
let compiler ;
40
40
let server ;
41
41
let pageErrors ;
42
42
let consoleMessages ;
43
43
44
- beforeEach ( async ( ) => {
44
+ test . beforeEach ( async ( ) => {
45
45
compiler = webpack ( config ) ;
46
46
47
47
server = new Server ( { port, bonjour : true } , compiler ) ;
@@ -52,7 +52,7 @@ describe("bonjour option", { tag: "@flaky" }, () => {
52
52
consoleMessages = [ ] ;
53
53
} ) ;
54
54
55
- afterEach ( async ( ) => {
55
+ test . afterEach ( async ( ) => {
56
56
await server . stop ( ) ;
57
57
} ) ;
58
58
@@ -71,35 +71,35 @@ describe("bonjour option", { tag: "@flaky" }, () => {
71
71
72
72
expect ( mockPublish . callCount ) . toBe ( 1 ) ;
73
73
74
- expect ( mockPublish . calledWith (
75
- {
74
+ expect (
75
+ mockPublish . calledWith ( {
76
76
name : `Webpack Dev Server ${ os . hostname ( ) } :${ port } ` ,
77
77
port,
78
78
type : "http" ,
79
79
subtypes : [ "webpack" ] ,
80
- }
81
- ) ) . toBeTruthy ( ) ;
80
+ } ) ,
81
+ ) . toBeTruthy ( ) ;
82
82
83
83
expect ( mockUnpublishAll . callCount ) . toBe ( 0 ) ;
84
84
expect ( mockDestroy . callCount ) . toBe ( 0 ) ;
85
85
86
- expect ( response . status ( ) ) . toMatchSnapshotWithArray ( ) ;
86
+ expect ( response . status ( ) ) . toMatchSnapshotWithArray ( "response status" ) ;
87
87
88
88
expect (
89
- consoleMessages . map ( ( message ) => message . text ( ) ) )
90
- . toMatchSnapshotWithArray ( ) ;
89
+ consoleMessages . map ( ( message ) => message . text ( ) ) ,
90
+ ) . toMatchSnapshotWithArray ( "console messages" ) ;
91
91
92
- expect ( pageErrors ) . toMatchSnapshotWithArray ( ) ;
92
+ expect ( pageErrors ) . toMatchSnapshotWithArray ( "page errors" ) ;
93
93
} ) ;
94
94
} ) ;
95
95
96
- describe ( "with 'server' option" , ( ) => {
96
+ test . describe ( "with 'server' option" , ( ) => {
97
97
let compiler ;
98
98
let server ;
99
99
let pageErrors ;
100
100
let consoleMessages ;
101
101
102
- beforeEach ( async ( ) => {
102
+ test . beforeEach ( async ( ) => {
103
103
compiler = webpack ( config ) ;
104
104
105
105
server = new Server ( { bonjour : true , port, server : "https" } , compiler ) ;
@@ -110,7 +110,7 @@ describe("bonjour option", { tag: "@flaky" }, () => {
110
110
consoleMessages = [ ] ;
111
111
} ) ;
112
112
113
- afterEach ( async ( ) => {
113
+ test . afterEach ( async ( ) => {
114
114
await server . stop ( ) ;
115
115
} ) ;
116
116
@@ -129,33 +129,35 @@ describe("bonjour option", { tag: "@flaky" }, () => {
129
129
130
130
expect ( mockPublish . callCount ) . toBe ( 1 ) ;
131
131
132
- expect ( mockPublish . calledWith ( {
133
- name : `Webpack Dev Server ${ os . hostname ( ) } :${ port } ` ,
134
- port,
135
- type : "https" ,
136
- subtypes : [ "webpack" ] ,
137
- } ) ) . toBeTruthy ( ) ;
132
+ expect (
133
+ mockPublish . calledWith ( {
134
+ name : `Webpack Dev Server ${ os . hostname ( ) } :${ port } ` ,
135
+ port,
136
+ type : "https" ,
137
+ subtypes : [ "webpack" ] ,
138
+ } ) ,
139
+ ) . toBeTruthy ( ) ;
138
140
139
141
expect ( mockUnpublishAll . callCount ) . toBe ( 0 ) ;
140
142
expect ( mockDestroy . callCount ) . toBe ( 0 ) ;
141
143
142
- expect ( response . status ( ) ) . toMatchSnapshotWithArray ( ) ;
144
+ expect ( response . status ( ) ) . toMatchSnapshotWithArray ( "response status" ) ;
143
145
144
146
expect (
145
- consoleMessages . map ( ( message ) => message . text ( ) ) )
146
- . toMatchSnapshotWithArray ( ) ;
147
+ consoleMessages . map ( ( message ) => message . text ( ) ) ,
148
+ ) . toMatchSnapshotWithArray ( "console messages" ) ;
147
149
148
- expect ( pageErrors ) . toMatchSnapshotWithArray ( ) ;
150
+ expect ( pageErrors ) . toMatchSnapshotWithArray ( "page errors" ) ;
149
151
} ) ;
150
152
} ) ;
151
153
152
- describe ( "as object" , ( ) => {
154
+ test . describe ( "as object" , ( ) => {
153
155
let compiler ;
154
156
let server ;
155
157
let pageErrors ;
156
158
let consoleMessages ;
157
159
158
- beforeEach ( async ( ) => {
160
+ test . beforeEach ( async ( ) => {
159
161
compiler = webpack ( config ) ;
160
162
161
163
server = new Server (
@@ -175,7 +177,7 @@ describe("bonjour option", { tag: "@flaky" }, () => {
175
177
consoleMessages = [ ] ;
176
178
} ) ;
177
179
178
- afterEach ( async ( ) => {
180
+ test . afterEach ( async ( ) => {
179
181
await server . stop ( ) ;
180
182
} ) ;
181
183
@@ -194,34 +196,36 @@ describe("bonjour option", { tag: "@flaky" }, () => {
194
196
195
197
expect ( mockPublish . callCount ) . toBe ( 1 ) ;
196
198
197
- expect ( mockPublish . calledWith ( {
198
- name : `Webpack Dev Server ${ os . hostname ( ) } :${ port } ` ,
199
- port,
200
- type : "https" ,
201
- protocol : "udp" ,
202
- subtypes : [ "webpack" ] ,
203
- } ) ) . toBeTruthy ( ) ;
199
+ expect (
200
+ mockPublish . calledWith ( {
201
+ name : `Webpack Dev Server ${ os . hostname ( ) } :${ port } ` ,
202
+ port,
203
+ type : "https" ,
204
+ protocol : "udp" ,
205
+ subtypes : [ "webpack" ] ,
206
+ } ) ,
207
+ ) . toBeTruthy ( ) ;
204
208
205
209
expect ( mockUnpublishAll . callCount ) . toBe ( 0 ) ;
206
210
expect ( mockDestroy . callCount ) . toBe ( 0 ) ;
207
211
208
- expect ( response . status ( ) ) . toMatchSnapshotWithArray ( ) ;
212
+ expect ( response . status ( ) ) . toMatchSnapshotWithArray ( "response status" ) ;
209
213
210
214
expect (
211
- consoleMessages . map ( ( message ) => message . text ( ) ) )
212
- . toMatchSnapshotWithArray ( ) ;
215
+ consoleMessages . map ( ( message ) => message . text ( ) ) ,
216
+ ) . toMatchSnapshotWithArray ( "console messages" ) ;
213
217
214
- expect ( pageErrors ) . toMatchSnapshotWithArray ( ) ;
218
+ expect ( pageErrors ) . toMatchSnapshotWithArray ( "page errors" ) ;
215
219
} ) ;
216
220
} ) ;
217
221
218
- describe ( "bonjour object and 'server' option" , ( ) => {
222
+ test . describe ( "bonjour object and 'server' option" , ( ) => {
219
223
let compiler ;
220
224
let server ;
221
225
let pageErrors ;
222
226
let consoleMessages ;
223
227
224
- beforeEach ( async ( ) => {
228
+ test . beforeEach ( async ( ) => {
225
229
compiler = webpack ( config ) ;
226
230
227
231
server = new Server (
@@ -244,7 +248,7 @@ describe("bonjour option", { tag: "@flaky" }, () => {
244
248
consoleMessages = [ ] ;
245
249
} ) ;
246
250
247
- afterEach ( async ( ) => {
251
+ test . afterEach ( async ( ) => {
248
252
await server . stop ( ) ;
249
253
} ) ;
250
254
@@ -263,24 +267,26 @@ describe("bonjour option", { tag: "@flaky" }, () => {
263
267
264
268
expect ( mockPublish . callCount ) . toBe ( 1 ) ;
265
269
266
- expect ( mockPublish . calledWith ( {
267
- name : `Webpack Dev Server ${ os . hostname ( ) } :${ port } ` ,
268
- port,
269
- type : "http" ,
270
- protocol : "udp" ,
271
- subtypes : [ "webpack" ] ,
272
- } ) ) . toBeTruthy ( ) ;
270
+ expect (
271
+ mockPublish . calledWith ( {
272
+ name : `Webpack Dev Server ${ os . hostname ( ) } :${ port } ` ,
273
+ port,
274
+ type : "http" ,
275
+ protocol : "udp" ,
276
+ subtypes : [ "webpack" ] ,
277
+ } ) ,
278
+ ) . toBeTruthy ( ) ;
273
279
274
280
expect ( mockUnpublishAll . callCount ) . toBe ( 0 ) ;
275
281
expect ( mockDestroy . callCount ) . toBe ( 0 ) ;
276
282
277
- expect ( response . status ( ) ) . toMatchSnapshotWithArray ( ) ;
283
+ expect ( response . status ( ) ) . toMatchSnapshotWithArray ( "response status" ) ;
278
284
279
285
expect (
280
- consoleMessages . map ( ( message ) => message . text ( ) ) )
281
- . toMatchSnapshotWithArray ( ) ;
286
+ consoleMessages . map ( ( message ) => message . text ( ) ) ,
287
+ ) . toMatchSnapshotWithArray ( "console messages" ) ;
282
288
283
- expect ( pageErrors ) . toMatchSnapshotWithArray ( ) ;
289
+ expect ( pageErrors ) . toMatchSnapshotWithArray ( "page errors" ) ;
284
290
} ) ;
285
291
} ) ;
286
292
} ) ;
0 commit comments