Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,8 @@ describe('NodeEnvironment', () => {
test('TextEncoder references the same global Uint8Array constructor', () => {
expect(new TextEncoder().encode('abc')).toBeInstanceOf(Uint8Array);
});

test('dispatch event', () => {
new EventTarget().dispatchEvent(new Event('foo'));
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

describe('NodeEnvironment 2', () => {
test('dispatch event', () => {
new EventTarget().dispatchEvent(new Event('foo'));
});
});
1 change: 1 addition & 0 deletions packages/jest-environment-node/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
Object.getOwnPropertyNames(global) as GlobalProperties,
);
for (const [nodeGlobalsKey, descriptor] of nodeGlobals) {
protectProperties(globalThis[nodeGlobalsKey]);

Check warning on line 105 in packages/jest-environment-node/src/index.ts

View check run for this annotation

Codecov / codecov/patch

packages/jest-environment-node/src/index.ts#L105

Added line #L105 was not covered by tests
if (!contextGlobals.has(nodeGlobalsKey)) {
if (descriptor.configurable) {
Object.defineProperty(global, nodeGlobalsKey, {
Expand Down
Loading