This repository was archived by the owner on Mar 13, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed
vitest-environment-miniflare/src Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -15,8 +15,9 @@ export function prefixError(prefix: string, e: any): Error {
1515 if ( e . stack ) {
1616 return new Proxy ( e , {
1717 get ( target , propertyKey , receiver ) {
18- const value = Reflect . get ( target , propertyKey , receiver ) ;
19- return propertyKey === "stack" ? `${ prefix } : ${ value } ` : value ;
18+ return propertyKey === "stack"
19+ ? `${ prefix } : ${ target . stack } `
20+ : Reflect . get ( target , propertyKey , receiver ) ;
2021 } ,
2122 } ) ;
2223 }
Original file line number Diff line number Diff line change @@ -99,6 +99,13 @@ export default <Environment>{
9999 delete mfGlobalScope . crypto ;
100100 Object . defineProperty ( global , "crypto" , { get : ( ) => crypto } ) ;
101101
102+ // `navigator` is defined as a getter on the global scope in Node 21+,
103+ // so attempting to set it with `Object.assign()` would fail. Instead,
104+ // override the getter with a new value.
105+ const navigator = mfGlobalScope . navigator ;
106+ delete mfGlobalScope . navigator ;
107+ Object . defineProperty ( global , "navigator" , { get : ( ) => navigator } ) ;
108+
102109 // Attach all Miniflare globals to `global`, recording originals to restore
103110 // in teardown
104111 const keys = Object . keys ( mfGlobalScope ) ;
You can’t perform that action at this time.
0 commit comments