jest-fixed-jsdom
Advanced tools
Comparing version 0.0.6 to 0.0.7
@@ -22,2 +22,4 @@ const JSDOMEnvironment = require('jest-environment-jsdom').default | ||
this.global.URLSearchParams = URLSearchParams | ||
this.global.BroadcastChannel = BroadcastChannel | ||
} | ||
@@ -24,0 +26,0 @@ } |
const { URL: BuiltinURL } = require('node:url') | ||
const { | ||
BroadcastChannel: BuiltinBroadcastChannel, | ||
} = require('node:worker_threads') | ||
@@ -41,3 +44,5 @@ test('exposes "Blob"', async () => { | ||
} | ||
expect(Buffer.from(chunks)).toEqual(Buffer.from(new Uint8Array([104, 101, 108, 108, 111]))) | ||
expect(Buffer.from(chunks)).toEqual( | ||
Buffer.from(new Uint8Array([104, 101, 108, 108, 111])), | ||
) | ||
}) | ||
@@ -143,4 +148,20 @@ | ||
expect(globalThis).toHaveProperty('URLSearchParams') | ||
expect(new URL('http://localhost?other_non_mocked_flag').searchParams.has('other_non_mocked_flag')).toBe(false) | ||
expect(new URL('http://localhost?other_non_mocked_flag').searchParams.has('mocked_flag')).toBe(true) | ||
expect( | ||
new URL('http://localhost?other_non_mocked_flag').searchParams.has( | ||
'other_non_mocked_flag', | ||
), | ||
).toBe(false) | ||
expect( | ||
new URL('http://localhost?other_non_mocked_flag').searchParams.has( | ||
'mocked_flag', | ||
), | ||
).toBe(true) | ||
}) | ||
test('exposes "BroadcastChannel"', () => { | ||
expect(globalThis).toHaveProperty('BroadcastChannel') | ||
const channel = new BroadcastChannel('foo') | ||
expect(channel).toBeInstanceOf(BuiltinBroadcastChannel) | ||
channel.unref() | ||
}) |
{ | ||
"name": "jest-fixed-jsdom", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "A superset of the JSDOM environment for Jest that respects Node.js globals.", | ||
@@ -5,0 +5,0 @@ "main": "./index.js", |
<h1 align="center">jest-fixed-jsdom</h1> | ||
<p align="center">A superset of the JSDOM environment for Jest that respects Node.js globals.</p> | ||
<!-- prettier-ignore-start --> | ||
> [!WARNING] | ||
> **This package is never meant as a solution to anything**. This is a workaround. Please consider testing browser code in the actual browser. You can do so both in [Vitest](https://vitest.dev/guide/browser/) and in [Playwright](https://playwright.dev/docs/test-components) at the moment. | ||
<!-- prettier-ignore-end --> | ||
## Motivation | ||
@@ -40,2 +45,3 @@ | ||
- `URLSearchParams` | ||
- `BroadcastChannel` | ||
@@ -42,0 +48,0 @@ ## Getting started |
Sorry, the diff of this file is not supported yet
11194
9
173
67