Skip to content

Commit 1b662b8

Browse files
committed
feat: replace jest with sinon
1 parent 5cd5658 commit 1b662b8

File tree

263 files changed

+1607
-1688
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

263 files changed

+1607
-1688
lines changed

test/e2e/allowed-hosts.test.js

Lines changed: 68 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,21 @@
22

33
const express = require("express");
44
const webpack = require("webpack");
5-
const { test } = require("@playwright/test");
6-
const { describe } = require("@playwright/test");
7-
const { expect } = require("@playwright/test");
8-
const { beforeEach, afterEach } = require("@playwright/test");
5+
const { describe, test, beforeEach, afterEach } = require("@playwright/test");
96
const { createProxyMiddleware } = require("http-proxy-middleware");
7+
const { expect } = require("../helpers/playwright-custom-expects");
108
const Server = require("../../lib/Server");
119
const config = require("../fixtures/client-config/webpack.config");
1210
const [port1, port2] = require("../ports-map")["allowed-hosts"];
1311

1412
const webSocketServers = ["ws", "sockjs"];
1513

16-
describe("allowed hosts", () => {
14+
describe("allowed hosts", {
15+
annotation: {
16+
type: "flaky",
17+
description: "https://github.com/webpack/webpack-dev-server/actions/runs/9957190252/job/27508687040"
18+
}
19+
}, () => {
1720
for (const webSocketServer of webSocketServers) {
1821
test(`should disconnect web socket client using custom hostname from web socket server with the "auto" value based on the "host" header ("${webSocketServer}")`, async ({
1922
page,
@@ -82,9 +85,8 @@ describe("allowed hosts", () => {
8285
});
8386

8487
expect(
85-
JSON.stringify(consoleMessages.map((message) => message.text())),
86-
).toMatchSnapshot();
87-
expect(JSON.stringify(pageErrors)).toMatchSnapshot();
88+
consoleMessages.map((message) => message.text())).toMatchSnapshotWithArray();
89+
expect(pageErrors).toMatchSnapshotWithArray();
8890
} catch (error) {
8991
throw error;
9092
} finally {
@@ -164,9 +166,8 @@ describe("allowed hosts", () => {
164166
});
165167

166168
expect(
167-
JSON.stringify(consoleMessages.map((message) => message.text())),
168-
).toMatchSnapshot();
169-
expect(JSON.stringify(pageErrors)).toMatchSnapshot();
169+
consoleMessages.map((message) => message.text())).toMatchSnapshotWithArray();
170+
expect(pageErrors).toMatchSnapshotWithArray();
170171
} catch (error) {
171172
throw error;
172173
} finally {
@@ -243,9 +244,8 @@ describe("allowed hosts", () => {
243244
});
244245

245246
expect(
246-
JSON.stringify(consoleMessages.map((message) => message.text())),
247-
).toMatchSnapshot();
248-
expect(JSON.stringify(pageErrors)).toMatchSnapshot();
247+
consoleMessages.map((message) => message.text())).toMatchSnapshotWithArray();
248+
expect(pageErrors).toMatchSnapshotWithArray();
249249
} catch (error) {
250250
throw error;
251251
} finally {
@@ -318,9 +318,8 @@ describe("allowed hosts", () => {
318318
});
319319

320320
expect(
321-
JSON.stringify(consoleMessages.map((message) => message.text())),
322-
).toMatchSnapshot();
323-
expect(JSON.stringify(pageErrors)).toMatchSnapshot();
321+
consoleMessages.map((message) => message.text())).toMatchSnapshotWithArray();
322+
expect(pageErrors).toMatchSnapshotWithArray();
324323
} catch (error) {
325324
throw error;
326325
} finally {
@@ -393,9 +392,8 @@ describe("allowed hosts", () => {
393392
});
394393

395394
expect(
396-
JSON.stringify(consoleMessages.map((message) => message.text())),
397-
).toMatchSnapshot();
398-
expect(JSON.stringify(pageErrors)).toMatchSnapshot();
395+
consoleMessages.map((message) => message.text())).toMatchSnapshotWithArray();
396+
expect(pageErrors).toMatchSnapshotWithArray();
399397
} catch (error) {
400398
throw error;
401399
} finally {
@@ -468,9 +466,8 @@ describe("allowed hosts", () => {
468466
});
469467

470468
expect(
471-
JSON.stringify(consoleMessages.map((message) => message.text())),
472-
).toMatchSnapshot();
473-
expect(JSON.stringify(pageErrors)).toMatchSnapshot();
469+
consoleMessages.map((message) => message.text())).toMatchSnapshotWithArray();
470+
expect(pageErrors).toMatchSnapshotWithArray();
474471
} catch (error) {
475472
throw error;
476473
} finally {
@@ -546,9 +543,8 @@ describe("allowed hosts", () => {
546543
});
547544

548545
expect(
549-
JSON.stringify(consoleMessages.map((message) => message.text())),
550-
).toMatchSnapshot();
551-
expect(JSON.stringify(pageErrors)).toMatchSnapshot();
546+
consoleMessages.map((message) => message.text())).toMatchSnapshotWithArray();
547+
expect(pageErrors).toMatchSnapshotWithArray();
552548
} catch (error) {
553549
throw error;
554550
} finally {
@@ -624,9 +620,8 @@ describe("allowed hosts", () => {
624620
});
625621

626622
expect(
627-
JSON.stringify(consoleMessages.map((message) => message.text())),
628-
).toMatchSnapshot();
629-
expect(JSON.stringify(pageErrors)).toMatchSnapshot();
623+
consoleMessages.map((message) => message.text())).toMatchSnapshotWithArray();
624+
expect(pageErrors).toMatchSnapshotWithArray();
630625
} catch (error) {
631626
throw error;
632627
} finally {
@@ -703,9 +698,8 @@ describe("allowed hosts", () => {
703698
});
704699

705700
expect(
706-
JSON.stringify(consoleMessages.map((message) => message.text())),
707-
).toMatchSnapshot();
708-
expect(JSON.stringify(pageErrors)).toMatchSnapshot();
701+
consoleMessages.map((message) => message.text())).toMatchSnapshotWithArray();
702+
expect(pageErrors).toMatchSnapshotWithArray();
709703
} catch (error) {
710704
throw error;
711705
} finally {
@@ -782,9 +776,8 @@ describe("allowed hosts", () => {
782776
});
783777

784778
expect(
785-
JSON.stringify(consoleMessages.map((message) => message.text())),
786-
).toMatchSnapshot();
787-
expect(JSON.stringify(pageErrors)).toMatchSnapshot();
779+
consoleMessages.map((message) => message.text())).toMatchSnapshotWithArray();
780+
expect(pageErrors).toMatchSnapshotWithArray();
788781
} catch (error) {
789782
throw error;
790783
} finally {
@@ -861,9 +854,8 @@ describe("allowed hosts", () => {
861854
});
862855

863856
expect(
864-
JSON.stringify(consoleMessages.map((message) => message.text())),
865-
).toMatchSnapshot();
866-
expect(JSON.stringify(pageErrors)).toMatchSnapshot();
857+
consoleMessages.map((message) => message.text())).toMatchSnapshotWithArray();
858+
expect(pageErrors).toMatchSnapshotWithArray();
867859
} catch (error) {
868860
throw error;
869861
} finally {
@@ -940,9 +932,8 @@ describe("allowed hosts", () => {
940932
});
941933

942934
expect(
943-
JSON.stringify(consoleMessages.map((message) => message.text())),
944-
).toMatchSnapshot();
945-
expect(JSON.stringify(pageErrors)).toMatchSnapshot();
935+
consoleMessages.map((message) => message.text())).toMatchSnapshotWithArray();
936+
expect(pageErrors).toMatchSnapshotWithArray();
946937
} catch (error) {
947938
throw error;
948939
} finally {
@@ -1022,9 +1013,8 @@ describe("allowed hosts", () => {
10221013
});
10231014

10241015
expect(
1025-
JSON.stringify(consoleMessages.map((message) => message.text())),
1026-
).toMatchSnapshot();
1027-
expect(JSON.stringify(pageErrors)).toMatchSnapshot();
1016+
consoleMessages.map((message) => message.text())).toMatchSnapshotWithArray();
1017+
expect(pageErrors).toMatchSnapshotWithArray();
10281018
} catch (error) {
10291019
throw error;
10301020
} finally {
@@ -1101,9 +1091,8 @@ describe("allowed hosts", () => {
11011091
});
11021092

11031093
expect(
1104-
JSON.stringify(consoleMessages.map((message) => message.text())),
1105-
).toMatchSnapshot();
1106-
expect(JSON.stringify(pageErrors)).toMatchSnapshot();
1094+
consoleMessages.map((message) => message.text())).toMatchSnapshotWithArray();
1095+
expect(pageErrors).toMatchSnapshotWithArray();
11071096
} catch (error) {
11081097
throw error;
11091098
} finally {
@@ -1182,11 +1171,10 @@ describe("allowed hosts", () => {
11821171

11831172
const html = await page.content();
11841173

1185-
expect(JSON.stringify(html)).toMatchSnapshot();
1174+
expect(html).toMatchSnapshotWithArray();
11861175
expect(
1187-
JSON.stringify(consoleMessages.map((message) => message.text())),
1188-
).toMatchSnapshot();
1189-
expect(JSON.stringify(pageErrors)).toMatchSnapshot();
1176+
consoleMessages.map((message) => message.text())).toMatchSnapshotWithArray();
1177+
expect(pageErrors).toMatchSnapshotWithArray();
11901178
} catch (error) {
11911179
throw error;
11921180
} finally {
@@ -1245,13 +1233,12 @@ describe("allowed hosts", () => {
12451233
throw new Error("Validation didn't fail");
12461234
}
12471235

1248-
expect(JSON.stringify(response.status())).toMatchSnapshot();
1236+
expect(response.status()).toMatchSnapshotWithArray();
12491237

12501238
expect(
1251-
JSON.stringify(consoleMessages.map((message) => message.text())),
1252-
).toMatchSnapshot();
1239+
consoleMessages.map((message) => message.text())).toMatchSnapshotWithArray();
12531240

1254-
expect(JSON.stringify(pageErrors)).toMatchSnapshot();
1241+
expect(pageErrors).toMatchSnapshotWithArray();
12551242
});
12561243

12571244
test("should always allow `localhost` subdomain if options.allowedHosts is auto", async ({
@@ -1286,16 +1273,21 @@ describe("allowed hosts", () => {
12861273
throw new Error("Validation didn't fail");
12871274
}
12881275

1289-
expect(JSON.stringify(response.status())).toMatchSnapshot();
1276+
expect(response.status()).toMatchSnapshotWithArray();
12901277

12911278
expect(
1292-
JSON.stringify(consoleMessages.map((message) => message.text())),
1293-
).toMatchSnapshot();
1279+
consoleMessages.map((message) => message.text())).toMatchSnapshotWithArray();
12941280

1295-
expect(JSON.stringify(pageErrors)).toMatchSnapshot();
1281+
expect(pageErrors).toMatchSnapshotWithArray();
12961282
});
12971283

1298-
test("should always allow value from the `host` options if options.allowedHosts is auto", async ({
1284+
// FIXME
1285+
test("should always allow value from the `host` options if options.allowedHosts is auto", {
1286+
annotation: {
1287+
type: "fails",
1288+
description: "https://github.com/webpack/webpack-dev-server/issues/4630#issuecomment-1588211112"
1289+
}
1290+
}, async ({
12991291
page,
13001292
}) => {
13011293
const networkIP = Server.internalIPSync("v4");
@@ -1329,13 +1321,12 @@ describe("allowed hosts", () => {
13291321
throw new Error("Validation didn't fail");
13301322
}
13311323

1332-
expect(JSON.stringify(response.status())).toMatchSnapshot();
1324+
expect(response.status()).toMatchSnapshotWithArray();
13331325

13341326
expect(
1335-
JSON.stringify(consoleMessages.map((message) => message.text())),
1336-
).toMatchSnapshot();
1327+
consoleMessages.map((message) => message.text())).toMatchSnapshotWithArray();
13371328

1338-
expect(JSON.stringify(pageErrors)).toMatchSnapshot();
1329+
expect(pageErrors).toMatchSnapshotWithArray();
13391330
});
13401331

13411332
test("should always allow value of the `host` option from the `client.webSocketURL` option if options.allowedHosts is auto", async ({
@@ -1373,13 +1364,12 @@ describe("allowed hosts", () => {
13731364
throw new Error("Validation didn't fail");
13741365
}
13751366

1376-
expect(JSON.stringify(response.status())).toMatchSnapshot();
1367+
expect(response.status()).toMatchSnapshotWithArray();
13771368

13781369
expect(
1379-
JSON.stringify(consoleMessages.map((message) => message.text())),
1380-
).toMatchSnapshot();
1370+
consoleMessages.map((message) => message.text())).toMatchSnapshotWithArray();
13811371

1382-
expect(JSON.stringify(pageErrors)).toMatchSnapshot();
1372+
expect(pageErrors).toMatchSnapshotWithArray();
13831373
});
13841374

13851375
test("should always allow any host if options.allowedHosts is all", async ({
@@ -1413,13 +1403,12 @@ describe("allowed hosts", () => {
14131403
throw new Error("Validation didn't fail");
14141404
}
14151405

1416-
expect(JSON.stringify(response.status())).toMatchSnapshot();
1406+
expect(response.status()).toMatchSnapshotWithArray();
14171407

14181408
expect(
1419-
JSON.stringify(consoleMessages.map((message) => message.text())),
1420-
).toMatchSnapshot();
1409+
consoleMessages.map((message) => message.text())).toMatchSnapshotWithArray();
14211410

1422-
expect(JSON.stringify(pageErrors)).toMatchSnapshot();
1411+
expect(pageErrors).toMatchSnapshotWithArray();
14231412
});
14241413

14251414
test("should allow hosts in allowedHosts", async ({ page }) => {
@@ -1453,13 +1442,12 @@ describe("allowed hosts", () => {
14531442
}
14541443
});
14551444

1456-
expect(JSON.stringify(response.status())).toMatchSnapshot();
1445+
expect(response.status()).toMatchSnapshotWithArray();
14571446

14581447
expect(
1459-
JSON.stringify(consoleMessages.map((message) => message.text())),
1460-
).toMatchSnapshot();
1448+
consoleMessages.map((message) => message.text())).toMatchSnapshotWithArray();
14611449

1462-
expect(JSON.stringify(pageErrors)).toMatchSnapshot();
1450+
expect(pageErrors).toMatchSnapshotWithArray();
14631451
});
14641452

14651453
test("should allow hosts that pass a wildcard in allowedHosts", async ({
@@ -1503,13 +1491,13 @@ describe("allowed hosts", () => {
15031491
}
15041492
});
15051493

1506-
expect(JSON.stringify(response.status())).toMatchSnapshot();
1494+
expect(response.status()).toMatchSnapshotWithArray();
15071495

15081496
expect(
1509-
JSON.stringify(consoleMessages.map((message) => message.text())),
1510-
).toMatchSnapshot();
1497+
consoleMessages.map((message) => message.text())).toMatchSnapshotWithArray();
15111498

1512-
expect(JSON.stringify(pageErrors)).toMatchSnapshot();
1499+
expect(pageErrors).toMatchSnapshotWithArray();
15131500
});
15141501
});
15151502
});
1503+

0 commit comments

Comments
 (0)