Skip to content

Commit dde0e0d

Browse files
1 parent 1fe55b4 commit dde0e0d

6 files changed

Lines changed: 72 additions & 6 deletions

File tree

‎test/harness/globalSetup.js‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@
55

66
"use strict";
77

8+
const path = require("path");
89
const { create } = require("../helpers/browserslistConfigPackages");
910

10-
module.exports = create;
11+
module.exports = () => {
12+
// Trust the self-signed certificate of the lazy-compilation https case, so
13+
// its client verifies it rather than turning verification off. Read when a
14+
// worker starts, so it has to be set here, before Jest spawns them.
15+
process.env.NODE_EXTRA_CA_CERTS = path.resolve(
16+
__dirname,
17+
"../hotCases/lazy-compilation/https/cert.pem"
18+
);
19+
20+
return create();
21+
};

‎test/harness/setupTestFramework.js‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,35 @@ if (process.env.DEBUG_INFO) {
139139
it = addDebugInfo(it);
140140
}
141141

142+
// parsing/asm-js holds "use asm" functions that are not valid asm.js on
143+
// purpose, and V8 reports each one it rejects on stderr. Run them as plain
144+
// JavaScript, as V8 does once it has rejected them.
145+
try {
146+
require("v8").setFlagsFromString("--no-validate-asm");
147+
} catch (_err) {
148+
// a runtime without V8 flags has no asm.js validation to report either
149+
}
150+
151+
// Experimental features the test runner enables on purpose; their warning on
152+
// every worker says nothing about the change under test.
153+
const realProcess = vm.runInThisContext("process");
154+
const originalEmitWarning = realProcess.emitWarning;
155+
// this file runs once per test file, while the process outlives them
156+
if (!originalEmitWarning.skipsKnownWarnings) {
157+
realProcess.emitWarning = function emitWarning(warning, ...args) {
158+
const type =
159+
typeof args[0] === "string" ? args[0] : args[0] && args[0].type;
160+
if (
161+
type === "ExperimentalWarning" &&
162+
/^(VM Modules|stripTypeScriptTypes) /.test(String(warning))
163+
) {
164+
return;
165+
}
166+
return originalEmitWarning.call(this, warning, ...args);
167+
};
168+
realProcess.emitWarning.skipsKnownWarnings = true;
169+
}
170+
142171
// cspell:word wabt
143172
// Workaround for a memory leak in wabt: it leaks an Error object on construction,
144173
// so it leaks the whole stack trace.

‎test/hotCases/css/mini-css-extract/a.js‎

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,30 @@ const readStyles = () =>
99
it("should apply a hot update to the extracted stylesheet", function (done) {
1010
expect(readStyles()).toContain("color: red;");
1111

12+
// mini-css-extract-plugin reports the reload on the console: check it there
13+
// rather than let it reach the test output
14+
const log = console.log;
15+
const logs = [];
16+
console.log = (...args) => {
17+
logs.push(args.join(" "));
18+
};
19+
const finish = (err) => {
20+
console.log = log;
21+
done(err);
22+
};
23+
1224
NEXT(
13-
require("../../update")(done, true, () => {
25+
require("../../update")(finish, true, () => {
1426
expect(readStyles()).toContain("color: blue;");
15-
16-
done();
27+
// the plugin debounces the reload by 50ms
28+
setTimeout(() => {
29+
try {
30+
expect(logs.join("\n")).toContain("Reload all css");
31+
} catch (err) {
32+
return finish(err);
33+
}
34+
finish();
35+
}, 100);
1736
})
1837
);
1938
});

‎test/hotCases/lazy-compilation/https/index.js‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
// Avoid errors because of self-signed certificate
2-
process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0;
1+
// Node.js trusts the self-signed certificate through NODE_EXTRA_CA_CERTS (see
2+
// test/harness/globalSetup.js); Bun and Deno need verification turned off
3+
if (process.versions.bun || process.versions.deno) {
4+
process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0;
5+
}
36

47
it("should compile to lazy imported module", (done) => {
58
let resolved;

‎test/hotCases/universal/dev-server-client/index.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import "./quiet-log";
12
import value from "./module";
23
// universal regular-HMR client: works on web (dev-server EventSource signal)
34
// and Node (same emitter signal) without a platform-specific client
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// hot/dev-server logs every step at "info"; keep only warnings and errors so
2+
// the test output stays quiet. Imported first, before the client logs.
3+
require("../../../../hot/log").setLogLevel("warning");

0 commit comments

Comments
 (0)