File tree Expand file tree Collapse file tree 3 files changed +30
-13
lines changed
Expand file tree Collapse file tree 3 files changed +30
-13
lines changed Original file line number Diff line number Diff line change 77
88import { plugins } from 'pretty-format' ;
99
10- const builtInObject = [
10+ const builtInObject : Array < unknown > = [
1111 Array ,
12- Buffer ,
1312 Date ,
1413 Float32Array ,
1514 Float64Array ,
@@ -25,6 +24,10 @@ const builtInObject = [
2524 Uint8ClampedArray ,
2625] ;
2726
27+ if ( typeof Buffer !== 'undefined' ) {
28+ builtInObject . push ( Buffer ) ;
29+ }
30+
2831const isBuiltInObject = ( object : any ) =>
2932 builtInObject . includes ( object . constructor ) ;
3033
Original file line number Diff line number Diff line change @@ -206,13 +206,24 @@ async function runTestInternal(
206206 } ,
207207 } ;
208208
209+ const isBrowserEnv = typeof environment . global ?. document !== 'undefined' ;
210+
209211 // For tests
210- runtime
211- . requireInternalModule < typeof import ( 'source-map-support' ) > (
212- require . resolve ( 'source-map-support' ) ,
213- 'source-map-support' ,
214- )
215- . install ( sourcemapOptions ) ;
212+ if ( isBrowserEnv ) {
213+ runtime . requireInternalModule (
214+ require . resolve ( 'source-map-support/browser-source-map-support' ) ,
215+ ) ;
216+ const sourceMapSupport = environment . global
217+ . sourceMapSupport as typeof sourcemapSupport ;
218+
219+ sourceMapSupport . install ( { ...sourcemapOptions , environment : 'browser' } ) ;
220+ } else {
221+ runtime
222+ . requireInternalModule < typeof sourcemapSupport > (
223+ require . resolve ( 'source-map-support' ) ,
224+ )
225+ . install ( sourcemapOptions ) ;
226+ }
216227
217228 // For runtime errors
218229 sourcemapSupport . install ( sourcemapOptions ) ;
Original file line number Diff line number Diff line change @@ -652,12 +652,10 @@ export default class Runtime {
652652
653653 if ( options ?. isInternalModule ) {
654654 moduleRegistry = this . _internalModuleRegistry ;
655+ } else if ( this . _isolatedModuleRegistry ) {
656+ moduleRegistry = this . _isolatedModuleRegistry ;
655657 } else {
656- if ( this . _isolatedModuleRegistry ) {
657- moduleRegistry = this . _isolatedModuleRegistry ;
658- } else {
659- moduleRegistry = this . _moduleRegistry ;
660- }
658+ moduleRegistry = this . _moduleRegistry ;
661659 }
662660
663661 const module = moduleRegistry . get ( modulePath ) ;
@@ -1823,6 +1821,11 @@ export default class Runtime {
18231821 throw moduleNotFoundError ;
18241822 }
18251823
1824+ e . message = `Jest: Got error evaluating ${ path . relative (
1825+ this . _config . rootDir ,
1826+ module . filename ,
1827+ ) } .\n${ e . message } `;
1828+
18261829 throw e ;
18271830 }
18281831
You can’t perform that action at this time.
0 commit comments