Skip to content

Commit e6e0957

Browse files
committed
refactor: migrate test files to ES module syntax
1 parent 250c87b commit e6e0957

66 files changed

Lines changed: 685 additions & 689 deletions

Some content is hidden

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

test/cli/allowedHosts-option.test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
"use strict";
1+
import { describe, it } from "node:test";
2+
import { expect } from "expect";
3+
import { testBin } from "../helpers/test-bin.js";
4+
import portsMap from "../ports-map.js";
25

3-
const { describe, it } = require("node:test");
4-
const { expect } = require("expect");
5-
const { testBin } = require("../helpers/test-bin");
6-
const port = require("../ports-map")["cli-allowed-hosts"];
6+
const port = portsMap["cli-allowed-hosts"];
77

88
describe('"allowedHosts" CLI option', () => {
99
it('should work using "--allowed-hosts auto"', async () => {

test/cli/basic.test.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
"use strict";
2-
3-
const path = require("node:path");
4-
const { describe, it } = require("node:test");
5-
const util = require("node:util");
6-
const execa = require("execa");
7-
const { expect } = require("expect");
8-
const { normalizeStderr, testBin } = require("../helpers/test-bin");
9-
const port = require("../ports-map")["cli-basic"];
1+
import path from "node:path";
2+
import { fileURLToPath } from "node:url";
3+
import { describe, it } from "node:test";
4+
import util from "node:util";
5+
import execa from "execa";
6+
import { expect } from "expect";
7+
import { normalizeStderr, testBin } from "../helpers/test-bin.js";
8+
import portsMap from "../ports-map.js";
9+
10+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
11+
const port = portsMap["cli-basic"];
1012

1113
const isMacOS = process.platform === "darwin";
1214

test/cli/bonjour-option.test.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
"use strict";
2-
3-
const fs = require("node:fs");
4-
const { beforeEach, describe, it } = require("node:test");
5-
const { expect } = require("expect");
6-
const Server = require("../../lib/Server");
7-
const { normalizeStderr, testBin } = require("../helpers/test-bin");
8-
const port = require("../ports-map")["cli-bonjour"];
1+
import fs from "node:fs";
2+
import { beforeEach, describe, it } from "node:test";
3+
import { expect } from "expect";
4+
import Server from "../../lib/Server.js";
5+
import { normalizeStderr, testBin } from "../helpers/test-bin.js";
6+
import portsMap from "../ports-map.js";
7+
8+
const port = portsMap["cli-bonjour"];
99

1010
const defaultCertificateDir = Server.findCacheDir();
1111

test/cli/client-option.test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
"use strict";
1+
import { describe, it } from "node:test";
2+
import { expect } from "expect";
3+
import { testBin } from "../helpers/test-bin.js";
4+
import portsMap from "../ports-map.js";
25

3-
const { describe, it } = require("node:test");
4-
const { expect } = require("expect");
5-
const { testBin } = require("../helpers/test-bin");
6-
const port = require("../ports-map")["cli-client"];
6+
const port = portsMap["cli-client"];
77

88
describe('"client" CLI option', () => {
99
it('should work using "--client-web-socket-transport ws"', async () => {

test/cli/colors.test.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
"use strict";
1+
import { describe, it } from "node:test";
2+
import { fileURLToPath } from "node:url";
3+
import { expect } from "expect";
4+
import { normalizeStderr, testBin } from "../helpers/test-bin.js";
5+
import portsMap from "../ports-map.js";
26

3-
const { describe, it } = require("node:test");
4-
const { expect } = require("expect");
5-
const { normalizeStderr, testBin } = require("../helpers/test-bin");
6-
const port = require("../ports-map")["cli-colors"];
7+
const port = portsMap["cli-colors"];
78

8-
const colorsDefaultStats = require.resolve(
9-
"../fixtures/cli-colors-default-stats/webpack.config",
9+
const colorsDefaultStats = fileURLToPath(
10+
import.meta.resolve("../fixtures/cli-colors-default-stats/webpack.config.js"),
1011
);
11-
const colorsDisabled = require.resolve(
12-
"../fixtures/cli-colors-disabled/webpack.config",
12+
const colorsDisabled = fileURLToPath(
13+
import.meta.resolve("../fixtures/cli-colors-disabled/webpack.config.js"),
1314
);
14-
const colorsEnabled = require.resolve(
15-
"../fixtures/cli-colors-enabled/webpack.config",
15+
const colorsEnabled = fileURLToPath(
16+
import.meta.resolve("../fixtures/cli-colors-enabled/webpack.config.js"),
1617
);
1718

1819
describe("colors", () => {

test/cli/compress-option.test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
"use strict";
1+
import { describe, it } from "node:test";
2+
import { expect } from "expect";
3+
import { testBin } from "../helpers/test-bin.js";
4+
import portsMap from "../ports-map.js";
25

3-
const { describe, it } = require("node:test");
4-
const { expect } = require("expect");
5-
const { testBin } = require("../helpers/test-bin");
6-
const port = require("../ports-map")["cli-compress"];
6+
const port = portsMap["cli-compress"];
77

88
describe('"compress" CLI option', () => {
99
it('should work using "--compress"', async () => {

test/cli/historyApiFallback-option.test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
"use strict";
1+
import { describe, it } from "node:test";
2+
import { expect } from "expect";
3+
import { normalizeStderr, testBin } from "../helpers/test-bin.js";
4+
import portsMap from "../ports-map.js";
25

3-
const { describe, it } = require("node:test");
4-
const { expect } = require("expect");
5-
const { normalizeStderr, testBin } = require("../helpers/test-bin");
6-
const port = require("../ports-map")["cli-history-api-fallback"];
6+
const port = portsMap["cli-history-api-fallback"];
77

88
describe('"historyApiFallback" CLI option', () => {
99
it('should work using "--history-api-fallback"', async (t) => {

test/cli/host-option.test.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
"use strict";
2-
3-
const os = require("node:os");
4-
const { describe, it } = require("node:test");
5-
const { expect } = require("expect");
6-
const { spyOn } = require("jest-mock");
7-
const Server = require("../../lib/Server");
8-
const { normalizeStderr, testBin } = require("../helpers/test-bin");
9-
const port = require("../ports-map")["cli-host"];
1+
import os from "node:os";
2+
import { describe, it } from "node:test";
3+
import { expect } from "expect";
4+
import { spyOn } from "jest-mock";
5+
import Server from "../../lib/Server.js";
6+
import { normalizeStderr, testBin } from "../helpers/test-bin.js";
7+
import portsMap from "../ports-map.js";
8+
9+
const port = portsMap["cli-host"];
1010

1111
const localIPv4 = Server.findIp("v4", false);
1212
const localIPv6 = Server.findIp("v6", false);

test/cli/hot-option.test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
"use strict";
1+
import { describe, it } from "node:test";
2+
import { expect } from "expect";
3+
import { testBin } from "../helpers/test-bin.js";
4+
import portsMap from "../ports-map.js";
25

3-
const { describe, it } = require("node:test");
4-
const { expect } = require("expect");
5-
const { testBin } = require("../helpers/test-bin");
6-
const port = require("../ports-map")["cli-hot"];
6+
const port = portsMap["cli-hot"];
77

88
describe('"hot" CLI option', () => {
99
it('should work using "--hot"', async () => {

test/cli/ipc-option.test.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
"use strict";
2-
3-
const os = require("node:os");
4-
const path = require("node:path");
5-
const { describe, it } = require("node:test");
6-
const { expect } = require("expect");
7-
const { normalizeStderr, testBin } = require("../helpers/test-bin");
1+
import os from "node:os";
2+
import path from "node:path";
3+
import { describe, it } from "node:test";
4+
import { expect } from "expect";
5+
import { normalizeStderr, testBin } from "../helpers/test-bin.js";
86

97
describe('"ipc" CLI option', () => {
108
it('should work using "--ipc"', async (t) => {

0 commit comments

Comments
 (0)