Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add readme, instructions and explanation #6

Merged
merged 7 commits into from
Mar 18, 2024
Merged

Conversation

JamesZoft
Copy link
Collaborator

No description provided.

Copy link
Collaborator

@tobiashochguertel tobiashochguertel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@kettanaito kettanaito changed the title add readme with intro, instructions and explanation docs: add readme, instructions and explanation Mar 18, 2024
README.md Outdated Show resolved Hide resolved
README.md Outdated

## Motivation

Jest strips out a number of NodeJS globals that are used in tests and libraries involving JSDOM, such as structuredClone, ReadableStream, and so on. This library patches these globals back in - there is no polyfilling or mocking involved, it simply re-attaches the missing globals to the JSDOM environment. If you've ever come across errors such as `ReferenceError: ReadableStream is not defined` or `ReferenceError: structuredClone is not defined`, this library is for you. If you were previously using (undici)[https://www.npmjs.com/package/undici] purely to solve this, you will no longer need it.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not entirely correct. There are a few things that happen in the Jest/JSDOM combo:

  • Some globals are stripped away, like ReadableSteam, TextEncoder, TextDecoder.
  • Some globals are present but are polyfilled by JSDOM or other libraries, making them incompatible with Node.js, e.g. Event and structuredClone().

If you want, I can help you rewrite this section. Let me know.

joel-daros
joel-daros previously approved these changes Mar 18, 2024
README.md Outdated

You will need to add/modify two properties in your jest configuration to use jest-fixed-jsdom.

```json
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to add a comment that mentions what file this is (jest.config.js).

@kettanaito
Copy link
Member

I've polished the readme a bit. Thank you for your work on this, @JamesZoft @tobiashochguertel! 👏

@kettanaito kettanaito merged commit 9a06836 into main Mar 18, 2024
1 check passed
@kettanaito kettanaito deleted the readme-firstpass branch March 18, 2024 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants