Skip to content

Commit 0835411

Browse files
test: move suite drivers into test/templates (#22159)
* test: move suite drivers into test/templates The four *.template.js drivers sat next to the *.test.js files they serve, so `ls test/` mixed suite infrastructure with the suites themselves. Move them to test/templates/ and drop the .template suffix the directory now carries. Each driver resolves case directories against a testRootDirectory constant instead of __dirname, since it now lives one level below test/. * docs: correct test/templates directory relationship templates/ is a sibling of the case directories, not below them.
1 parent b48cd77 commit 0835411

35 files changed

Lines changed: 144 additions & 129 deletions

‎AGENTS.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ The directory listings below are the canonical map of the repository. **Whenever
105105

106106
**Tests** — see [TESTING_DOCS.md](TESTING_DOCS.md) for directory structure, naming, and how to run a single case.
107107

108-
- `test/` — All test suites (`unitCases/`, `cases/`, `configCases/`, `specCases/`, `watchCases/`, `hotCases/`, `statsCases/`, `typesCases/`, `test262-cases/`, `html5lib-tests/`, `wpt/`, `css-parsing-tests/`, `benchmarkCases/`, `memoryLimitCases/`, etc.). `RoundTripConfigCases` re-bundles the output of `configCases` marked with a `roundTrip.js` file. `wpt/` is web-platform-tests, checked out one commit deep by the `html5lib` and `syntax-equivalence` jobs — it is where the HTML tree-construction corpus lives since html5lib-tests dropped it.
108+
- `test/` — All test suites (`unitCases/`, `cases/`, `configCases/`, `specCases/`, `watchCases/`, `hotCases/`, `statsCases/`, `typesCases/`, `test262-cases/`, `html5lib-tests/`, `wpt/`, `css-parsing-tests/`, `benchmarkCases/`, `memoryLimitCases/`, etc.). `templates/` holds the suite drivers (`TestCases.js`, `ConfigTestCases.js`, `HotTestCases.js`, `WatchTestCases.js`) that the `*.test.js` / `*.basictest.js` / `*.longtest.js` files at the top of `test/` are thin shims over — each exports `describeCases(config)` and resolves case directories against the `test/` root, never against its own. `RoundTripConfigCases` re-bundles the output of `configCases` marked with a `roundTrip.js` file. `wpt/` is web-platform-tests, checked out one commit deep by the `html5lib` and `syntax-equivalence` jobs — it is where the HTML tree-construction corpus lives since html5lib-tests dropped it.
109109

110110
**Git submodules** — the spec-conformance corpora are submodules, checked out on demand: `yarn setup` does not fetch them, and each CI job fetches only the submodules it needs, one commit deep.
111111

‎TESTING_DOCS.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ This document explains the structure of the `test/` directory in the Webpack pro
4141
- **Purpose**: Utility functions and scripts to assist in testing.
4242
- **Usage**: Provides reusable functions for mock data generation, cleanup, and assertions.
4343

44+
### 6b. `templates/`
45+
46+
- **Purpose**: The suite drivers — `TestCases.js`, `ConfigTestCases.js`, `HotTestCases.js`, `WatchTestCases.js` — each exporting `describeCases(config)`.
47+
- **Usage**: The `*.test.js` / `*.basictest.js` / `*.longtest.js` files at the top of `test/` are thin shims that call `describeCases` with one suite's options, so one driver serves every variant (targets, devtools, cache modes). Jest parallelizes per file, which is why the variants stay separate files rather than being folded into one.
48+
- **Note**: `templates/` is a sibling of the case directories it runs (`cases/`, `configCases/`, `hotCases/`, `watchCases/`), so a driver resolves paths from the shared `test/` root via `testRootDirectory` (`path.join(__dirname, "..")`), never against `__dirname`.
49+
4450
### 7. `hotCases/`
4551

4652
- **Purpose**: Focuses on Webpack’s Hot Module Replacement (HMR) functionality.

‎eslint.config.mjs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export default defineConfig([
2020
"!test/**/deprecations.js",
2121
"!test/**/infrastructure-log.js",
2222
"!test/helpers/*.*",
23+
"!test/templates/*.js",
2324
"!test/specCases/*.js",
2425
"!test/benchmarkCases/**/*.mjs",
2526
"!test/harness/benchmark/**/*.mjs",

‎test/ConfigCacheTestCases.basictest.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use strict";
22

3-
const { describeCases } = require("./ConfigTestCases.template");
3+
const { describeCases } = require("./templates/ConfigTestCases");
44

55
describeCases({
66
name: "ConfigCacheTestCases",

‎test/ConfigTestCases.basictest.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use strict";
22

3-
const { describeCases } = require("./ConfigTestCases.template");
3+
const { describeCases } = require("./templates/ConfigTestCases");
44

55
describeCases({
66
name: "ConfigTestCases"

‎test/HotTestCasesAsyncNode.test.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use strict";
22

3-
const { describeCases } = require("./HotTestCases.template");
3+
const { describeCases } = require("./templates/HotTestCases");
44

55
describe("HotTestCases", () => {
66
describeCases({

‎test/HotTestCasesNode.test.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use strict";
22

3-
const { describeCases } = require("./HotTestCases.template");
3+
const { describeCases } = require("./templates/HotTestCases");
44

55
describe("HotTestCases", () => {
66
describeCases({

‎test/HotTestCasesUniversal.test.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use strict";
22

3-
const { describeCases } = require("./HotTestCases.template");
3+
const { describeCases } = require("./templates/HotTestCases");
44

55
describe("HotTestCases", () => {
66
describeCases({

‎test/HotTestCasesWeb.test.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use strict";
22

3-
const { describeCases } = require("./HotTestCases.template");
3+
const { describeCases } = require("./templates/HotTestCases");
44

55
describe("HotTestCases", () => {
66
describeCases({

‎test/HotTestCasesWebWorker.test.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use strict";
22

3-
const { describeCases } = require("./HotTestCases.template");
3+
const { describeCases } = require("./templates/HotTestCases");
44

55
describe("HotTestCases", () => {
66
describeCases({

0 commit comments

Comments
 (0)