File tree Expand file tree Collapse file tree
universal/dev-server-client Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55
66"use strict" ;
77
8+ const path = require ( "path" ) ;
89const { 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+ } ;
Original file line number Diff line number Diff 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+ / ^ ( V M M o d u l e s | s t r i p T y p e S c r i p t T y p e s ) / . 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.
Original file line number Diff line number Diff line change @@ -9,11 +9,30 @@ const readStyles = () =>
99it ( "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} ) ;
Original file line number Diff line number Diff line change 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
47it ( "should compile to lazy imported module" , ( done ) => {
58 let resolved ;
Original file line number Diff line number Diff line change 1+ import "./quiet-log" ;
12import 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
Original file line number Diff line number Diff line change 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" ) ;
You can’t perform that action at this time.
0 commit comments