Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jest-fixed-jsdom

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jest-fixed-jsdom - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

4

index.js

@@ -11,6 +11,2 @@ const JSDOMEnvironment = require('jest-environment-jsdom').default

this.global.EventTarget = EventTarget
this.global.Event = Event
this.global.MessageEvent = MessageEvent
this.global.Blob = Blob

@@ -17,0 +13,0 @@ this.global.Headers = Headers

@@ -91,62 +91,1 @@ test('exposes "Blob"', async () => {

test('exposes "EventTarget"', () => {
expect(globalThis).toHaveProperty('EventTarget')
expect(() => new EventTarget()).not.toThrow()
const target = new EventTarget()
const symbols = Object.getOwnPropertySymbols(target).map(
(symbol) => symbol.description,
)
// EventTarget must not be implemented by JSDOM.
expect(symbols).not.toContain('impl')
// In Node.js, EventTarget keeps events behind the kEvents symbol.
expect(symbols).toContain('kEvents')
})
test('exposes "Event"', () => {
expect(globalThis).toHaveProperty('Event')
expect(() => new Event('click')).not.toThrow()
const event = new Event('click')
const symbols = Object.getOwnPropertySymbols(event).map(
(symbol) => symbol.description,
)
// The "impl" symbol is added by JSDOM.
expect(symbols).not.toContain('impl')
// Node.js expects events to have the "type" symbol.
expect(symbols).toContain('type')
/**
* Perform a basic "isEvent()" check that Node.js has.
* @see https://github.com/nodejs/node/blob/3a456c6db802b5b25594d3a9d235d4989e9f7829/lib/internal/event_target.js#L96
*/
expect(event[symbols.find((description) => description === 'type')]).toBe(
'click',
)
})
test('exposes "MessageEvent"', () => {
expect(globalThis).toHaveProperty('MessageEvent')
expect(() => new MessageEvent('click')).not.toThrow()
const event = new MessageEvent('message')
const symbols = Object.getOwnPropertySymbols(event).map(
(symbol) => symbol.description,
)
// The "impl" symbol is added by JSDOM.
expect(symbols).not.toContain('impl')
// Node.js expects events to have the "type" symbol.
expect(symbols).toContain('type')
/**
* Perform a basic "isEvent()" check that Node.js has.
* @see https://github.com/nodejs/node/blob/3a456c6db802b5b25594d3a9d235d4989e9f7829/lib/internal/event_target.js#L96
*/
expect(event[symbols.find((description) => description === 'type')]).toBe(
'message',
)
})

2

package.json
{
"name": "jest-fixed-jsdom",
"version": "0.0.1",
"version": "0.0.2",
"description": "A superset of the JSDOM environment for Jest that respects Node.js globals.",

@@ -5,0 +5,0 @@ "main": "./index.js",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc