1
1
"use strict" ;
2
2
3
3
const webpack = require ( "webpack" ) ;
4
- const { describe, test, beforeEach, afterEach } = require ( "@playwright/test" ) ;
5
4
const Server = require ( "../../lib/Server" ) ;
6
5
const { expect } = require ( "../helpers/playwright-custom-expects" ) ;
6
+ const { test } = require ( "../helpers/playwright-test" ) ;
7
7
const config = require ( "../fixtures/simple-config-other/webpack.config" ) ;
8
8
const port = require ( "../ports-map" ) [ "compress-option" ] ;
9
9
10
- describe ( "compress option" , { tag : [ "@flaky" , "@fails" ] } , ( ) => {
11
- describe ( "enabled by default when not specified" , ( ) => {
10
+ test . describe ( "compress option" , { tag : [ "@flaky" , "@fails" ] } , ( ) => {
11
+ test . describe ( "enabled by default when not specified" , ( ) => {
12
12
let compiler ;
13
13
let server ;
14
14
let pageErrors ;
15
15
let consoleMessages ;
16
16
17
- beforeEach ( async ( ) => {
17
+ test . beforeEach ( async ( ) => {
18
18
compiler = webpack ( config ) ;
19
19
20
20
server = new Server ( { port } , compiler ) ;
@@ -25,7 +25,7 @@ describe("compress option", { tag: ["@flaky", "@fails"] }, () => {
25
25
consoleMessages = [ ] ;
26
26
} ) ;
27
27
28
- afterEach ( async ( ) => {
28
+ test . afterEach ( async ( ) => {
29
29
await server . stop ( ) ;
30
30
} ) ;
31
31
@@ -42,25 +42,27 @@ describe("compress option", { tag: ["@flaky", "@fails"] }, () => {
42
42
waitUntil : "networkidle0" ,
43
43
} ) ;
44
44
45
- expect ( response . status ( ) ) . toMatchSnapshotWithArray ( ) ;
45
+ expect ( response . status ( ) ) . toMatchSnapshotWithArray ( "response status" ) ;
46
46
47
- expect ( response . headers ( ) [ "content-encoding" ] ) . toMatchSnapshotWithArray ( ) ;
47
+ expect ( response . headers ( ) [ "content-encoding" ] ) . toMatchSnapshotWithArray (
48
+ "response headers" ,
49
+ ) ;
48
50
49
51
expect (
50
52
consoleMessages . map ( ( message ) => message . text ( ) ) ,
51
- ) . toMatchSnapshotWithArray ( ) ;
53
+ ) . toMatchSnapshotWithArray ( "console messages" ) ;
52
54
53
- expect ( pageErrors ) . toMatchSnapshotWithArray ( ) ;
55
+ expect ( pageErrors ) . toMatchSnapshotWithArray ( "page errors" ) ;
54
56
} ) ;
55
57
} ) ;
56
58
57
- describe ( "as true" , ( ) => {
59
+ test . describe ( "as true" , ( ) => {
58
60
let compiler ;
59
61
let server ;
60
62
let pageErrors ;
61
63
let consoleMessages ;
62
64
63
- beforeEach ( async ( ) => {
65
+ test . beforeEach ( async ( ) => {
64
66
compiler = webpack ( config ) ;
65
67
66
68
server = new Server (
@@ -77,7 +79,7 @@ describe("compress option", { tag: ["@flaky", "@fails"] }, () => {
77
79
consoleMessages = [ ] ;
78
80
} ) ;
79
81
80
- afterEach ( async ( ) => {
82
+ test . afterEach ( async ( ) => {
81
83
await server . stop ( ) ;
82
84
} ) ;
83
85
@@ -94,25 +96,27 @@ describe("compress option", { tag: ["@flaky", "@fails"] }, () => {
94
96
waitUntil : "networkidle0" ,
95
97
} ) ;
96
98
97
- expect ( response . status ( ) ) . toMatchSnapshotWithArray ( ) ;
99
+ expect ( response . status ( ) ) . toMatchSnapshotWithArray ( "response status" ) ;
98
100
99
- expect ( response . headers ( ) [ "content-encoding" ] ) . toMatchSnapshotWithArray ( ) ;
101
+ expect ( response . headers ( ) [ "content-encoding" ] ) . toMatchSnapshotWithArray (
102
+ "response headers" ,
103
+ ) ;
100
104
101
105
expect (
102
106
consoleMessages . map ( ( message ) => message . text ( ) ) ,
103
- ) . toMatchSnapshotWithArray ( ) ;
107
+ ) . toMatchSnapshotWithArray ( "console messages" ) ;
104
108
105
- expect ( pageErrors ) . toMatchSnapshotWithArray ( ) ;
109
+ expect ( pageErrors ) . toMatchSnapshotWithArray ( "page errors" ) ;
106
110
} ) ;
107
111
} ) ;
108
112
109
- describe ( "as false" , ( ) => {
113
+ test . describe ( "as false" , ( ) => {
110
114
let compiler ;
111
115
let server ;
112
116
let pageErrors ;
113
117
let consoleMessages ;
114
118
115
- beforeEach ( async ( ) => {
119
+ test . beforeEach ( async ( ) => {
116
120
compiler = webpack ( config ) ;
117
121
118
122
server = new Server (
@@ -129,7 +133,7 @@ describe("compress option", { tag: ["@flaky", "@fails"] }, () => {
129
133
consoleMessages = [ ] ;
130
134
} ) ;
131
135
132
- afterEach ( async ( ) => {
136
+ test . afterEach ( async ( ) => {
133
137
await server . stop ( ) ;
134
138
} ) ;
135
139
@@ -156,20 +160,20 @@ describe("compress option", { tag: ["@flaky", "@fails"] }, () => {
156
160
waitUntil : "networkidle0" ,
157
161
} ) ;
158
162
159
- expect ( response . status ( ) ) . toMatchSnapshotWithArray ( ) ;
163
+ expect ( response . status ( ) ) . toMatchSnapshotWithArray ( "response status" ) ;
160
164
161
165
// the response sometimes is []
162
166
// and sometimes {"accept-ranges": "bytes", "connection": "keep-alive", "content-length": "276518", "content-type": "application/javascript; charset=utf-8", "date": "Wed, 24 Jul 2024 12:49:54 GMT", "keep-alive": "timeout=5", "x-powered-by": "Express"}
163
167
// the thing is that the content-encoding does not exist in the response headers object
164
- expect (
165
- response . headers ( ) [ "content-encoding" ] ,
166
- ) . toMatchSnapshotWithArray ( ) ;
168
+ // expect(
169
+ // response.headers()["content-encoding"],
170
+ // ).toMatchSnapshotWithArray();
167
171
168
172
expect (
169
173
consoleMessages . map ( ( message ) => message . text ( ) ) ,
170
- ) . toMatchSnapshotWithArray ( ) ;
174
+ ) . toMatchSnapshotWithArray ( "console messages" ) ;
171
175
172
- expect ( pageErrors ) . toMatchSnapshotWithArray ( ) ;
176
+ expect ( pageErrors ) . toMatchSnapshotWithArray ( "page errors" ) ;
173
177
} ,
174
178
) ;
175
179
} ) ;
0 commit comments