test: hotTest and watchTest no longer auto setup jsdom env (#19676)
Github Actions / lint (push) Waiting to run Details
Github Actions / validate-legacy-node (push) Waiting to run Details
Github Actions / benchmark (1/4) (push) Waiting to run Details
Github Actions / benchmark (2/4) (push) Waiting to run Details
Github Actions / benchmark (3/4) (push) Waiting to run Details
Github Actions / benchmark (4/4) (push) Waiting to run Details
Github Actions / basic (push) Waiting to run Details
Github Actions / unit (push) Waiting to run Details
Github Actions / integration (10.x, macos-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (10.x, macos-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (10.x, ubuntu-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (10.x, ubuntu-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (10.x, windows-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (10.x, windows-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (12.x, ubuntu-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (14.x, ubuntu-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (16.x, ubuntu-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (18.x, ubuntu-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (20.x, macos-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (20.x, macos-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (20.x, ubuntu-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (20.x, ubuntu-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (20.x, windows-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (20.x, windows-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (22.x, macos-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (22.x, macos-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (22.x, ubuntu-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (22.x, ubuntu-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (22.x, windows-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (22.x, windows-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (24.x, macos-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (24.x, macos-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (24.x, ubuntu-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (24.x, ubuntu-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (24.x, windows-latest, a) (push) Blocked by required conditions Details
Github Actions / integration (24.x, windows-latest, b) (push) Blocked by required conditions Details
Github Actions / integration (lts/*, ubuntu-latest, a, 1) (push) Blocked by required conditions Details
Github Actions / integration (lts/*, ubuntu-latest, b, 1) (push) Blocked by required conditions Details

This commit is contained in:
hai-x 2025-07-10 02:38:53 +08:00 committed by GitHub
parent 09a7a97ab4
commit 24b1ec7611
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 60 additions and 9 deletions

View File

@ -157,8 +157,7 @@ const describeCases = config => {
outputDirectory,
testMeta: {
category: category.name,
name: testName,
env: "jsdom"
name: testName
},
testConfig: {
...testConfig,
@ -167,6 +166,10 @@ const describeCases = config => {
webpackOptions: options
});
if (testConfig.moduleScope) {
testConfig.moduleScope(runner._moduleScope, options);
}
function _next(callback) {
fakeUpdateLoaderOptions.updateIndex++;
compiler.run((err, stats) => {

View File

@ -305,8 +305,7 @@ const describeCases = config => {
outputDirectory,
testMeta: {
category: category.name,
name: testName,
env: "jsdom"
name: testName
},
testConfig: {
...testConfig,

View File

@ -4,5 +4,6 @@ module.exports = {
link.rel = "stylesheet";
link.href = "https://test.cases/path/bundle.css";
scope.window.document.head.appendChild(link);
}
},
env: "jsdom"
};

View File

@ -0,0 +1,3 @@
module.exports = {
env: "jsdom"
};

View File

@ -0,0 +1,3 @@
module.exports = {
env: "jsdom"
};

View File

@ -0,0 +1,3 @@
module.exports = {
env: "jsdom"
};

View File

@ -4,5 +4,6 @@ module.exports = {
link.rel = "stylesheet";
link.href = "https://test.cases/path/bundle.css";
scope.window.document.head.appendChild(link);
}
},
env: "jsdom"
};

View File

@ -4,5 +4,6 @@ module.exports = {
link.rel = "stylesheet";
link.href = "https://test.cases/path/bundle.css";
scope.window.document.head.appendChild(link);
}
},
env: "jsdom"
};

View File

@ -0,0 +1,9 @@
module.exports = {
moduleScope(scope, options) {
const FakeWorker = require("../../../helpers/createFakeWorker")({
outputDirectory: options.output.path
});
scope.Worker = FakeWorker;
}
};

View File

@ -0,0 +1,9 @@
module.exports = {
moduleScope(scope, options) {
const FakeWorker = require("../../../helpers/createFakeWorker")({
outputDirectory: options.output.path
});
scope.Worker = FakeWorker;
}
};

View File

@ -0,0 +1,9 @@
module.exports = {
moduleScope(scope, options) {
const FakeWorker = require("../../../helpers/createFakeWorker")({
outputDirectory: options.output.path
});
scope.Worker = FakeWorker;
}
};

View File

@ -58,7 +58,6 @@ const urlToRelativePath = url => {
* @typedef {object} TestMeta
* @property {string} category
* @property {string} name
* @property {"jsdom"=} env
* @property {number=} round
*/
@ -68,6 +67,7 @@ const urlToRelativePath = url => {
* @property {EXPECTED_FUNCTION=} moduleScope
* @property {EXPECTED_FUNCTION=} nonEsmThis
* @property {boolean=} evaluateScriptOnAttached
* @property {"jsdom"=} env
*/
/**
@ -110,15 +110,25 @@ class TestRunner {
testConfig,
webpackOptions
}) {
/** @type {string|string[]} */
this.target = target;
/** @type {string} */
this.outputDirectory = outputDirectory;
/** @type {TestConfig} */
this.testConfig = testConfig || {};
/** @type {TestMeta} */
this.testMeta = testMeta || {};
/** @type {EXPECTED_ANY} */
this.webpackOptions = webpackOptions || {};
/** @type {boolean} */
this._runInNewContext = this.isTargetWeb();
/** @type {EXPECTED_ANY} */
this._globalContext = this.createBaseGlobalContext();
/** @type {EXPECTED_ANY} */
this._moduleScope = this.createBaseModuleScope();
/** @type {ModuleRunner} */
this._moduleRunners = this.createModuleRunners();
/** @type {EXPECTED_ANY} */
this._esmContext = this.createBaseEsmContext();
}
@ -167,7 +177,7 @@ class TestRunner {
* @returns {boolean} whether env is jsdom
*/
jsDom() {
return this.testMeta.env === "jsdom" || this.isTargetWeb();
return this.testConfig.env === "jsdom" || this.isTargetWeb();
}
/**