Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit c9e4aa5

Browse files
committed
Add more detail to some jest-environment-miniflare comments
1 parent c65d986 commit c9e4aa5

File tree

1 file changed

+7
-2
lines changed
  • packages/jest-environment-miniflare/src

1 file changed

+7
-2
lines changed

packages/jest-environment-miniflare/src/index.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff 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) => {

0 commit comments

Comments
 (0)