Skip to content

Commit 383bbc9

Browse files
committed
chore: fix tests on windows
1 parent c5b9473 commit 383bbc9

File tree

2 files changed

+69
-44
lines changed

2 files changed

+69
-44
lines changed

test/e2e/server.test.js

+69-30
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ const { test } = require("../helpers/playwright-test");
1111
const { expect } = require("../helpers/playwright-custom-expects");
1212
const Server = require("../../lib/Server");
1313
const config = require("../fixtures/static-config/webpack.config");
14-
const { skipTestOnWindows } = require("../helpers/conditional-test");
1514
const customHTTP = require("../helpers/custom-http");
1615
const normalizeOptions = require("../helpers/normalize-options");
1716
const port = require("../ports-map")["server-option"];
@@ -82,7 +81,9 @@ test.describe("server option", () => {
8281

8382
await expect(page).toHaveScreenshot();
8483

85-
expect(consoleMessages.map((message) => message.text())).toMatchSnapshotWithArray("console messages");
84+
expect(
85+
consoleMessages.map((message) => message.text()),
86+
).toMatchSnapshotWithArray("console messages");
8687

8788
expect(pageErrors).toMatchSnapshotWithArray("page errors");
8889
});
@@ -138,7 +139,7 @@ test.describe("server option", () => {
138139
await expect(page).toHaveScreenshot();
139140

140141
expect(
141-
consoleMessages.map((message) => message.text())
142+
consoleMessages.map((message) => message.text()),
142143
).toMatchSnapshotWithArray("console messages");
143144

144145
expect(pageErrors).toMatchSnapshotWithArray("page errors");
@@ -194,7 +195,9 @@ test.describe("server option", () => {
194195

195196
await expect(page).toHaveScreenshot();
196197

197-
expect(consoleMessages.map((message) => message.text())).toMatchSnapshotWithArray("console messages");
198+
expect(
199+
consoleMessages.map((message) => message.text()),
200+
).toMatchSnapshotWithArray("console messages");
198201

199202
expect(pageErrors).toMatchSnapshotWithArray("page errors");
200203
});
@@ -250,7 +253,7 @@ test.describe("server option", () => {
250253
await expect(page).toHaveScreenshot();
251254

252255
expect(
253-
consoleMessages.map((message) => message.text())
256+
consoleMessages.map((message) => message.text()),
254257
).toMatchSnapshotWithArray("console messages");
255258

256259
expect(pageErrors).toMatchSnapshotWithArray("page errors");
@@ -333,10 +336,14 @@ test.describe("server option", () => {
333336
waitUntil: "networkidle0",
334337
});
335338

336-
expect(normalizeOptions(createServerSpy.getCall(0).args[0])).toMatchSnapshotWithArray();
339+
expect(
340+
normalizeOptions(createServerSpy.getCall(0).args[0]),
341+
).toMatchSnapshotWithArray();
337342
expect(response.status()).toBe(200);
338343
await expect(page).toHaveScreenshot();
339-
expect(consoleMessages.map((message) => message.text())).toMatchSnapshotWithArray("console messages");
344+
expect(
345+
consoleMessages.map((message) => message.text()),
346+
).toMatchSnapshotWithArray("console messages");
340347
expect(pageErrors).toMatchSnapshotWithArray("page errors");
341348
});
342349
});
@@ -413,10 +420,14 @@ test.describe("server option", () => {
413420
waitUntil: "networkidle0",
414421
});
415422

416-
expect(normalizeOptions(createServerSpy.getCall(0).args[0])).toMatchSnapshotWithArray();
423+
expect(
424+
normalizeOptions(createServerSpy.getCall(0).args[0]),
425+
).toMatchSnapshotWithArray();
417426
expect(response.status()).toBe(200);
418427
await expect(page).toHaveScreenshot();
419-
expect(consoleMessages.map((message) => message.text())).toMatchSnapshotWithArray("console messages");
428+
expect(
429+
consoleMessages.map((message) => message.text()),
430+
).toMatchSnapshotWithArray("console messages");
420431
expect(pageErrors).toMatchSnapshotWithArray("page errors");
421432
});
422433
});
@@ -502,10 +513,14 @@ test.describe("server option", () => {
502513
waitUntil: "networkidle0",
503514
});
504515

505-
expect(normalizeOptions(createServerSpy.getCall(0).args[0])).toMatchSnapshotWithArray();
516+
expect(
517+
normalizeOptions(createServerSpy.getCall(0).args[0]),
518+
).toMatchSnapshotWithArray();
506519
expect(response.status()).toBe(200);
507520
await expect(page).toHaveScreenshot();
508-
expect(consoleMessages.map((message) => message.text())).toMatchSnapshotWithArray("console messages");
521+
expect(
522+
consoleMessages.map((message) => message.text()),
523+
).toMatchSnapshotWithArray("console messages");
509524
expect(pageErrors).toMatchSnapshotWithArray("page errors");
510525
});
511526
});
@@ -568,10 +583,14 @@ test.describe("server option", () => {
568583
waitUntil: "networkidle0",
569584
});
570585

571-
expect(normalizeOptions(createServerSpy.getCall(0).args[0])).toMatchSnapshotWithArray();
586+
expect(
587+
normalizeOptions(createServerSpy.getCall(0).args[0]),
588+
).toMatchSnapshotWithArray();
572589
expect(response.status()).toBe(200);
573590
await expect(page).toHaveScreenshot();
574-
expect(consoleMessages.map((message) => message.text())).toMatchSnapshotWithArray("console messages");
591+
expect(
592+
consoleMessages.map((message) => message.text()),
593+
).toMatchSnapshotWithArray("console messages");
575594
expect(pageErrors).toMatchSnapshotWithArray("page errors");
576595
});
577596
});
@@ -634,16 +653,21 @@ test.describe("server option", () => {
634653
waitUntil: "networkidle0",
635654
});
636655

637-
expect(normalizeOptions(createServerSpy.getCall(0).args[0])).toMatchSnapshotWithArray();
656+
expect(
657+
normalizeOptions(createServerSpy.getCall(0).args[0]),
658+
).toMatchSnapshotWithArray();
638659
expect(response.status()).toBe(200);
639660
await expect(page).toHaveScreenshot();
640-
expect(consoleMessages.map((message) => message.text())).toMatchSnapshotWithArray("console messages");
661+
expect(
662+
consoleMessages.map((message) => message.text()),
663+
).toMatchSnapshotWithArray("console messages");
641664
expect(pageErrors).toMatchSnapshotWithArray("page errors");
642665
});
643666
});
644667

645668
test.describe("ca, pfx, key and cert are symlinks", () => {
646-
if (skipTestOnWindows("Symlinks are not supported on Windows")) {
669+
// Skip test on Windows because symlinks are not supported
670+
if (process.platform === "win32") {
647671
return;
648672
}
649673

@@ -707,7 +731,9 @@ test.describe("server option", () => {
707731
waitUntil: "networkidle0",
708732
});
709733

710-
expect(normalizeOptions(createServerSpy.getCall(0).args[0])).toMatchSnapshotWithArray("normalize options");
734+
expect(
735+
normalizeOptions(createServerSpy.getCall(0).args[0]),
736+
).toMatchSnapshotWithArray("normalize options");
711737
expect(response.status()).toEqual(200);
712738
expect(await response.text()).toContain("Heyo");
713739
expect(consoleMessages.map((message) => message.text())).toEqual([]);
@@ -781,10 +807,14 @@ test.describe("server option", () => {
781807
waitUntil: "networkidle0",
782808
});
783809

784-
expect(normalizeOptions(createServerSpy.getCall(0).args[0])).toMatchSnapshotWithArray("normalize options");
810+
expect(
811+
normalizeOptions(createServerSpy.getCall(0).args[0]),
812+
).toMatchSnapshotWithArray("normalize options");
785813
expect(response.status()).toBe(200);
786814
await expect(page).toHaveScreenshot();
787-
expect(consoleMessages.map((message) => message.text())).toMatchSnapshotWithArray("console messages");
815+
expect(
816+
consoleMessages.map((message) => message.text()),
817+
).toMatchSnapshotWithArray("console messages");
788818
expect(pageErrors).toMatchSnapshotWithArray("page errors");
789819
});
790820
});
@@ -862,10 +892,14 @@ test.describe("server option", () => {
862892
waitUntil: "networkidle0",
863893
});
864894

865-
expect(normalizeOptions(createServerSpy.getCall(0).args[0])).toMatchSnapshotWithArray("normalize options");
895+
expect(
896+
normalizeOptions(createServerSpy.getCall(0).args[0]),
897+
).toMatchSnapshotWithArray("normalize options");
866898
expect(response.status()).toBe(200);
867899
await expect(page).toHaveScreenshot();
868-
expect(consoleMessages.map((message) => message.text())).toMatchSnapshotWithArray("console messages");
900+
expect(
901+
consoleMessages.map((message) => message.text()),
902+
).toMatchSnapshotWithArray("console messages");
869903
expect(pageErrors).toMatchSnapshotWithArray("page errors");
870904
});
871905
});
@@ -949,11 +983,12 @@ test.describe("server option", () => {
949983
});
950984

951985
expect(
952-
normalizeOptions(createServerSpy.getCall(0).args[0])).toMatchSnapshotWithArray("normalize options");
986+
normalizeOptions(createServerSpy.getCall(0).args[0]),
987+
).toMatchSnapshotWithArray("normalize options");
953988
expect(response.status()).toBe(200);
954989
await expect(page).toHaveScreenshot();
955990
expect(
956-
consoleMessages.map((message) => message.text())
991+
consoleMessages.map((message) => message.text()),
957992
).toMatchSnapshotWithArray("console messages");
958993
expect(pageErrors).toMatchSnapshotWithArray("page errors");
959994
});
@@ -1026,12 +1061,12 @@ test.describe("server option", () => {
10261061
});
10271062

10281063
expect(
1029-
normalizeOptions(createServerSpy.getCall(0).args[0])
1064+
normalizeOptions(createServerSpy.getCall(0).args[0]),
10301065
).toMatchSnapshotWithArray("normalize options");
10311066
expect(response.status()).toBe(200);
10321067
await expect(page).toHaveScreenshot();
10331068
expect(
1034-
consoleMessages.map((message) => message.text())
1069+
consoleMessages.map((message) => message.text()),
10351070
).toMatchSnapshotWithArray("console messages");
10361071
expect(pageErrors).toMatchSnapshotWithArray("page errors");
10371072
});
@@ -1088,7 +1123,9 @@ test.describe("server option", () => {
10881123
});
10891124

10901125
test("should pass options to the 'https.createServer' method", async () => {
1091-
expect(normalizeOptions(createServerSpy.getCall(0).args[0])).toMatchSnapshotWithArray("normalize options");
1126+
expect(
1127+
normalizeOptions(createServerSpy.getCall(0).args[0]),
1128+
).toMatchSnapshotWithArray("normalize options");
10921129
});
10931130

10941131
test("should handle GET request to index route (/)", async () => {
@@ -1163,11 +1200,12 @@ test.describe("server option", () => {
11631200

11641201
expect(HTTPVersion).toEqual("h2");
11651202
expect(
1166-
normalizeOptions(createServerSpy.getCall(0).args[0])).toMatchSnapshotWithArray("normalize options");
1203+
normalizeOptions(createServerSpy.getCall(0).args[0]),
1204+
).toMatchSnapshotWithArray("normalize options");
11671205
expect(response.status()).toBe(200);
11681206
await expect(page).toHaveScreenshot();
11691207
expect(
1170-
consoleMessages.map((message) => message.text())
1208+
consoleMessages.map((message) => message.text()),
11711209
).toMatchSnapshotWithArray("console messages");
11721210
expect(pageErrors).toMatchSnapshotWithArray("page errors");
11731211
});
@@ -1232,11 +1270,12 @@ test.describe("server option", () => {
12321270

12331271
expect(HTTPVersion).toEqual("http/1.1");
12341272
expect(
1235-
normalizeOptions(createServerSpy.getCall(0).args[0])).toMatchSnapshotWithArray("normalize options");
1273+
normalizeOptions(createServerSpy.getCall(0).args[0]),
1274+
).toMatchSnapshotWithArray("normalize options");
12361275
expect(response.status()).toBe(200);
12371276
await expect(page).toHaveScreenshot();
12381277
expect(
1239-
consoleMessages.map((message) => message.text())
1278+
consoleMessages.map((message) => message.text()),
12401279
).toMatchSnapshotWithArray("console messages");
12411280
expect(pageErrors).toMatchSnapshotWithArray("page errors");
12421281
});

test/helpers/conditional-test.js

-14
This file was deleted.

0 commit comments

Comments
 (0)