File tree 1 file changed +8
-3
lines changed
packages/jest-environment-jsdom/src
1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,13 @@ export default class JSDOMEnvironment implements JestEnvironment<number> {
31
31
moduleMocker : ModuleMocker | null ;
32
32
33
33
constructor ( config : Config . ProjectConfig , options ?: EnvironmentContext ) {
34
+ const anyConsole = options ?. console ?? console ;
35
+ const virtualConsole = new VirtualConsole ( ) ;
36
+ virtualConsole . sendTo ( anyConsole , { omitJSDOMErrors : true } ) ;
37
+ virtualConsole . on ( 'jsdomError' , ( error ) => {
38
+ anyConsole . error ( error ) ;
39
+ } ) ;
40
+
34
41
this . dom = new JSDOM (
35
42
typeof config . testEnvironmentOptions . html === 'string'
36
43
? config . testEnvironmentOptions . html
@@ -45,9 +52,7 @@ export default class JSDOMEnvironment implements JestEnvironment<number> {
45
52
: undefined ,
46
53
runScripts : 'dangerously' ,
47
54
url : config . testURL ,
48
- virtualConsole : new VirtualConsole ( ) . sendTo (
49
- options ?. console || console ,
50
- ) ,
55
+ virtualConsole,
51
56
...config . testEnvironmentOptions ,
52
57
} ,
53
58
) ;
You can’t perform that action at this time.
0 commit comments