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 7
7
8
8
import { plugins } from 'pretty-format' ;
9
9
10
- const builtInObject = [
10
+ const builtInObject : Array < unknown > = [
11
11
Array ,
12
- Buffer ,
13
12
Date ,
14
13
Float32Array ,
15
14
Float64Array ,
@@ -25,6 +24,10 @@ const builtInObject = [
25
24
Uint8ClampedArray ,
26
25
] ;
27
26
27
+ if ( typeof Buffer !== 'undefined' ) {
28
+ builtInObject . push ( Buffer ) ;
29
+ }
30
+
28
31
const isBuiltInObject = ( object : any ) =>
29
32
builtInObject . includes ( object . constructor ) ;
30
33
Original file line number Diff line number Diff line change @@ -206,13 +206,24 @@ async function runTestInternal(
206
206
} ,
207
207
} ;
208
208
209
+ const isBrowserEnv = typeof environment . global ?. document !== 'undefined' ;
210
+
209
211
// 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
+ }
216
227
217
228
// For runtime errors
218
229
sourcemapSupport . install ( sourcemapOptions ) ;
Original file line number Diff line number Diff line change @@ -652,12 +652,10 @@ export default class Runtime {
652
652
653
653
if ( options ?. isInternalModule ) {
654
654
moduleRegistry = this . _internalModuleRegistry ;
655
+ } else if ( this . _isolatedModuleRegistry ) {
656
+ moduleRegistry = this . _isolatedModuleRegistry ;
655
657
} else {
656
- if ( this . _isolatedModuleRegistry ) {
657
- moduleRegistry = this . _isolatedModuleRegistry ;
658
- } else {
659
- moduleRegistry = this . _moduleRegistry ;
660
- }
658
+ moduleRegistry = this . _moduleRegistry ;
661
659
}
662
660
663
661
const module = moduleRegistry . get ( modulePath ) ;
@@ -1823,6 +1821,11 @@ export default class Runtime {
1823
1821
throw moduleNotFoundError ;
1824
1822
}
1825
1823
1824
+ e . message = `Jest: Got error evaluating ${ path . relative (
1825
+ this . _config . rootDir ,
1826
+ module . filename ,
1827
+ ) } .\n${ e . message } `;
1828
+
1826
1829
throw e ;
1827
1830
}
1828
1831
You can’t perform that action at this time.
0 commit comments