|
2 | 2 |
|
3 | 3 | const express = require("express");
|
4 | 4 | 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"); |
9 | 6 | const { createProxyMiddleware } = require("http-proxy-middleware");
|
| 7 | +const { expect } = require("../helpers/playwright-custom-expects"); |
10 | 8 | const Server = require("../../lib/Server");
|
11 | 9 | const config = require("../fixtures/client-config/webpack.config");
|
12 | 10 | const [port1, port2] = require("../ports-map")["allowed-hosts"];
|
13 | 11 |
|
14 | 12 | const webSocketServers = ["ws", "sockjs"];
|
15 | 13 |
|
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 | +}, () => { |
17 | 20 | for (const webSocketServer of webSocketServers) {
|
18 | 21 | test(`should disconnect web socket client using custom hostname from web socket server with the "auto" value based on the "host" header ("${webSocketServer}")`, async ({
|
19 | 22 | page,
|
@@ -82,9 +85,8 @@ describe("allowed hosts", () => {
|
82 | 85 | });
|
83 | 86 |
|
84 | 87 | 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(); |
88 | 90 | } catch (error) {
|
89 | 91 | throw error;
|
90 | 92 | } finally {
|
@@ -164,9 +166,8 @@ describe("allowed hosts", () => {
|
164 | 166 | });
|
165 | 167 |
|
166 | 168 | 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(); |
170 | 171 | } catch (error) {
|
171 | 172 | throw error;
|
172 | 173 | } finally {
|
@@ -243,9 +244,8 @@ describe("allowed hosts", () => {
|
243 | 244 | });
|
244 | 245 |
|
245 | 246 | 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(); |
249 | 249 | } catch (error) {
|
250 | 250 | throw error;
|
251 | 251 | } finally {
|
@@ -318,9 +318,8 @@ describe("allowed hosts", () => {
|
318 | 318 | });
|
319 | 319 |
|
320 | 320 | 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(); |
324 | 323 | } catch (error) {
|
325 | 324 | throw error;
|
326 | 325 | } finally {
|
@@ -393,9 +392,8 @@ describe("allowed hosts", () => {
|
393 | 392 | });
|
394 | 393 |
|
395 | 394 | 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(); |
399 | 397 | } catch (error) {
|
400 | 398 | throw error;
|
401 | 399 | } finally {
|
@@ -468,9 +466,8 @@ describe("allowed hosts", () => {
|
468 | 466 | });
|
469 | 467 |
|
470 | 468 | 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(); |
474 | 471 | } catch (error) {
|
475 | 472 | throw error;
|
476 | 473 | } finally {
|
@@ -546,9 +543,8 @@ describe("allowed hosts", () => {
|
546 | 543 | });
|
547 | 544 |
|
548 | 545 | 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(); |
552 | 548 | } catch (error) {
|
553 | 549 | throw error;
|
554 | 550 | } finally {
|
@@ -624,9 +620,8 @@ describe("allowed hosts", () => {
|
624 | 620 | });
|
625 | 621 |
|
626 | 622 | 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(); |
630 | 625 | } catch (error) {
|
631 | 626 | throw error;
|
632 | 627 | } finally {
|
@@ -703,9 +698,8 @@ describe("allowed hosts", () => {
|
703 | 698 | });
|
704 | 699 |
|
705 | 700 | 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(); |
709 | 703 | } catch (error) {
|
710 | 704 | throw error;
|
711 | 705 | } finally {
|
@@ -782,9 +776,8 @@ describe("allowed hosts", () => {
|
782 | 776 | });
|
783 | 777 |
|
784 | 778 | 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(); |
788 | 781 | } catch (error) {
|
789 | 782 | throw error;
|
790 | 783 | } finally {
|
@@ -861,9 +854,8 @@ describe("allowed hosts", () => {
|
861 | 854 | });
|
862 | 855 |
|
863 | 856 | 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(); |
867 | 859 | } catch (error) {
|
868 | 860 | throw error;
|
869 | 861 | } finally {
|
@@ -940,9 +932,8 @@ describe("allowed hosts", () => {
|
940 | 932 | });
|
941 | 933 |
|
942 | 934 | 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(); |
946 | 937 | } catch (error) {
|
947 | 938 | throw error;
|
948 | 939 | } finally {
|
@@ -1022,9 +1013,8 @@ describe("allowed hosts", () => {
|
1022 | 1013 | });
|
1023 | 1014 |
|
1024 | 1015 | 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(); |
1028 | 1018 | } catch (error) {
|
1029 | 1019 | throw error;
|
1030 | 1020 | } finally {
|
@@ -1101,9 +1091,8 @@ describe("allowed hosts", () => {
|
1101 | 1091 | });
|
1102 | 1092 |
|
1103 | 1093 | 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(); |
1107 | 1096 | } catch (error) {
|
1108 | 1097 | throw error;
|
1109 | 1098 | } finally {
|
@@ -1182,11 +1171,10 @@ describe("allowed hosts", () => {
|
1182 | 1171 |
|
1183 | 1172 | const html = await page.content();
|
1184 | 1173 |
|
1185 |
| - expect(JSON.stringify(html)).toMatchSnapshot(); |
| 1174 | + expect(html).toMatchSnapshotWithArray(); |
1186 | 1175 | 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(); |
1190 | 1178 | } catch (error) {
|
1191 | 1179 | throw error;
|
1192 | 1180 | } finally {
|
@@ -1245,13 +1233,12 @@ describe("allowed hosts", () => {
|
1245 | 1233 | throw new Error("Validation didn't fail");
|
1246 | 1234 | }
|
1247 | 1235 |
|
1248 |
| - expect(JSON.stringify(response.status())).toMatchSnapshot(); |
| 1236 | + expect(response.status()).toMatchSnapshotWithArray(); |
1249 | 1237 |
|
1250 | 1238 | expect(
|
1251 |
| - JSON.stringify(consoleMessages.map((message) => message.text())), |
1252 |
| - ).toMatchSnapshot(); |
| 1239 | + consoleMessages.map((message) => message.text())).toMatchSnapshotWithArray(); |
1253 | 1240 |
|
1254 |
| - expect(JSON.stringify(pageErrors)).toMatchSnapshot(); |
| 1241 | + expect(pageErrors).toMatchSnapshotWithArray(); |
1255 | 1242 | });
|
1256 | 1243 |
|
1257 | 1244 | test("should always allow `localhost` subdomain if options.allowedHosts is auto", async ({
|
@@ -1286,16 +1273,21 @@ describe("allowed hosts", () => {
|
1286 | 1273 | throw new Error("Validation didn't fail");
|
1287 | 1274 | }
|
1288 | 1275 |
|
1289 |
| - expect(JSON.stringify(response.status())).toMatchSnapshot(); |
| 1276 | + expect(response.status()).toMatchSnapshotWithArray(); |
1290 | 1277 |
|
1291 | 1278 | expect(
|
1292 |
| - JSON.stringify(consoleMessages.map((message) => message.text())), |
1293 |
| - ).toMatchSnapshot(); |
| 1279 | + consoleMessages.map((message) => message.text())).toMatchSnapshotWithArray(); |
1294 | 1280 |
|
1295 |
| - expect(JSON.stringify(pageErrors)).toMatchSnapshot(); |
| 1281 | + expect(pageErrors).toMatchSnapshotWithArray(); |
1296 | 1282 | });
|
1297 | 1283 |
|
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 ({ |
1299 | 1291 | page,
|
1300 | 1292 | }) => {
|
1301 | 1293 | const networkIP = Server.internalIPSync("v4");
|
@@ -1329,13 +1321,12 @@ describe("allowed hosts", () => {
|
1329 | 1321 | throw new Error("Validation didn't fail");
|
1330 | 1322 | }
|
1331 | 1323 |
|
1332 |
| - expect(JSON.stringify(response.status())).toMatchSnapshot(); |
| 1324 | + expect(response.status()).toMatchSnapshotWithArray(); |
1333 | 1325 |
|
1334 | 1326 | expect(
|
1335 |
| - JSON.stringify(consoleMessages.map((message) => message.text())), |
1336 |
| - ).toMatchSnapshot(); |
| 1327 | + consoleMessages.map((message) => message.text())).toMatchSnapshotWithArray(); |
1337 | 1328 |
|
1338 |
| - expect(JSON.stringify(pageErrors)).toMatchSnapshot(); |
| 1329 | + expect(pageErrors).toMatchSnapshotWithArray(); |
1339 | 1330 | });
|
1340 | 1331 |
|
1341 | 1332 | 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", () => {
|
1373 | 1364 | throw new Error("Validation didn't fail");
|
1374 | 1365 | }
|
1375 | 1366 |
|
1376 |
| - expect(JSON.stringify(response.status())).toMatchSnapshot(); |
| 1367 | + expect(response.status()).toMatchSnapshotWithArray(); |
1377 | 1368 |
|
1378 | 1369 | expect(
|
1379 |
| - JSON.stringify(consoleMessages.map((message) => message.text())), |
1380 |
| - ).toMatchSnapshot(); |
| 1370 | + consoleMessages.map((message) => message.text())).toMatchSnapshotWithArray(); |
1381 | 1371 |
|
1382 |
| - expect(JSON.stringify(pageErrors)).toMatchSnapshot(); |
| 1372 | + expect(pageErrors).toMatchSnapshotWithArray(); |
1383 | 1373 | });
|
1384 | 1374 |
|
1385 | 1375 | test("should always allow any host if options.allowedHosts is all", async ({
|
@@ -1413,13 +1403,12 @@ describe("allowed hosts", () => {
|
1413 | 1403 | throw new Error("Validation didn't fail");
|
1414 | 1404 | }
|
1415 | 1405 |
|
1416 |
| - expect(JSON.stringify(response.status())).toMatchSnapshot(); |
| 1406 | + expect(response.status()).toMatchSnapshotWithArray(); |
1417 | 1407 |
|
1418 | 1408 | expect(
|
1419 |
| - JSON.stringify(consoleMessages.map((message) => message.text())), |
1420 |
| - ).toMatchSnapshot(); |
| 1409 | + consoleMessages.map((message) => message.text())).toMatchSnapshotWithArray(); |
1421 | 1410 |
|
1422 |
| - expect(JSON.stringify(pageErrors)).toMatchSnapshot(); |
| 1411 | + expect(pageErrors).toMatchSnapshotWithArray(); |
1423 | 1412 | });
|
1424 | 1413 |
|
1425 | 1414 | test("should allow hosts in allowedHosts", async ({ page }) => {
|
@@ -1453,13 +1442,12 @@ describe("allowed hosts", () => {
|
1453 | 1442 | }
|
1454 | 1443 | });
|
1455 | 1444 |
|
1456 |
| - expect(JSON.stringify(response.status())).toMatchSnapshot(); |
| 1445 | + expect(response.status()).toMatchSnapshotWithArray(); |
1457 | 1446 |
|
1458 | 1447 | expect(
|
1459 |
| - JSON.stringify(consoleMessages.map((message) => message.text())), |
1460 |
| - ).toMatchSnapshot(); |
| 1448 | + consoleMessages.map((message) => message.text())).toMatchSnapshotWithArray(); |
1461 | 1449 |
|
1462 |
| - expect(JSON.stringify(pageErrors)).toMatchSnapshot(); |
| 1450 | + expect(pageErrors).toMatchSnapshotWithArray(); |
1463 | 1451 | });
|
1464 | 1452 |
|
1465 | 1453 | test("should allow hosts that pass a wildcard in allowedHosts", async ({
|
@@ -1503,13 +1491,13 @@ describe("allowed hosts", () => {
|
1503 | 1491 | }
|
1504 | 1492 | });
|
1505 | 1493 |
|
1506 |
| - expect(JSON.stringify(response.status())).toMatchSnapshot(); |
| 1494 | + expect(response.status()).toMatchSnapshotWithArray(); |
1507 | 1495 |
|
1508 | 1496 | expect(
|
1509 |
| - JSON.stringify(consoleMessages.map((message) => message.text())), |
1510 |
| - ).toMatchSnapshot(); |
| 1497 | + consoleMessages.map((message) => message.text())).toMatchSnapshotWithArray(); |
1511 | 1498 |
|
1512 |
| - expect(JSON.stringify(pageErrors)).toMatchSnapshot(); |
| 1499 | + expect(pageErrors).toMatchSnapshotWithArray(); |
1513 | 1500 | });
|
1514 | 1501 | });
|
1515 | 1502 | });
|
| 1503 | + |
0 commit comments