jaredLunde / jaredLunde/react-hook
jest-environment-jsdom 28+ tries to use browser exports instead of default exports
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.5k
- Forks
- 96
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
`jest-environment-jsdom` v28+ tries to use `browser` exports instead of default exports which generates the following error when Jest `testEnvironment: 'jsdom'`:
```
Jest encountered an unexpected token
Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.
```
**To Reproduce**
Steps to reproduce the behavior:
1. `git clone https://github.com/alex-l-miro/react-hook-bug.git`
2. `yarn`
3. `yarn test`
**Expected behavior**
Jest should not fail when `testEnvironment` is `jsdom`
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Clone the linked react-hook-bug reproduction, run yarn and yarn test, and confirm the failure with testEnvironment set to jsdom. Then inspect this project's Jest and test-environment configuration; done means Jest runs successfully without the unexpected-token error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100