jaredLunde / jaredLunde/react-hook

jest-environment-jsdom 28+ tries to use browser exports instead of default exports

Open
#300 9 comments 12 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.