Skip to content

Commit

Permalink
readme: jest no longer uses jsdom environment by default
Browse files Browse the repository at this point in the history
Node testEnvironment is made the default in v27 (https://jestjs.io/blog/2021/05/25/jest-27).
  • Loading branch information
siddharthvp committed May 29, 2021
1 parent f52cabc commit 42cb6c6
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ Licensed under the _Lesser_ General Public License. Can be used from any reposit

### Use with Jest

If you're using Jest's default test environment `jest-environment-jsdom`, just tweak your `jest.config.js` to include:
If you're using Jest, tweak your `jest.config.js` to include: (jsdom testEnvironment used to be the default till Jest v26)
```
"testEnvironment": "jsdom",
"setupFilesAfterEnv": ["mock-mediawiki"]
```

Done! All your Jest tests will now have access to `mw` and `$` as globals. This setup works with both CommonJS module format and ESM.

Jest exposes globally most browser-only globals available via jsdom. So if your gadget code includes references to `HTMLSpanElement` or `XMLDocument` et al, they'll just work!
Jest exposes globally most DOM APIs available via jsdom. So if your gadget code includes references to `HTMLSpanElement` or `XMLDocument` et al, they'll just work!

### Use with other test runners

Expand Down

0 comments on commit 42cb6c6

Please sign in to comment.