This repository was archived by the owner on Mar 13, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
packages/jest-environment-miniflare/src Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -118,7 +118,10 @@ export default class MiniflareEnvironment implements JestEnvironment {
118118 storageFactory : this . storageFactory ,
119119 scriptRunner : this . scriptRunner ,
120120 // Only run the script if we're using Durable Objects and need to have
121- // access to the exported classes
121+ // access to the exported classes. This means we're only running the
122+ // script in modules mode, so we don't need to worry about
123+ // addEventListener being called twice (once when the script is run, and
124+ // again when the user imports the worker in Jest tests).
122125 scriptRunForModuleExports : true ,
123126 } ,
124127 {
@@ -161,7 +164,9 @@ export default class MiniflareEnvironment implements JestEnvironment {
161164 Object . assign ( global , mfGlobalScope ) ;
162165 Object . assign ( global , proxiedGlobals ) ;
163166
164- // Add a way of getting bindings in modules mode to allow seeding data
167+ // Add a way of getting bindings in modules mode to allow seeding data.
168+ // These names are intentionally verbose so they don't collide with anything
169+ // else in scope.
165170 const bindings = await mf . getBindings ( ) ;
166171 global . getMiniflareBindings = ( ) => bindings ;
167172 global . getMiniflareDurableObjectStorage = async ( id : DurableObjectId ) => {
You can’t perform that action at this time.
0 commit comments