Nextjs with jest example will not work if there is an esm dependency in node_modules
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 142k
- Forks
- 32.4k
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 351
Description
Verify canary release
- I verified that the issue exists in the latest Next.js canary release
Provide environment information
Operating System:
Platform: linux
Arch: x64
Version: #1 SMP Fri Apr 2 22:23:49 UTC 2021
Binaries:
Node: 16.16.0
npm: 8.11.0
Yarn: 1.22.19
pnpm: N/A
Relevant packages:
next: 12.2.5
eslint-config-next: 12.2.5
react: 18.2.0
react-dom: 18.2.0
Which example does this report relate to?
https://nextjs.org/docs/testing
What browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
Describe the Bug
If you have a project with a dependency that is published as an es modules in node_modules, running jest will not work..even though nextjs works with it e.g. running the project normally with npm run dev.
Test does not run even if ignoring the package. Please check this repo that reproduce the problem:
https://github.com/wmira/banana/
if you run npm run dev here..works fine.. npm run test here does not and this follow the jest example.
Expected Behavior
running test via jest works as per the docs
To Reproduce
repo is below:
https://github.com/wmira/banana/
- npm run dev -- nextjs works fine with an es module dependency under node_modules
- npm run test -- throws error
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
Start by reproducing the failure in the linked banana repository with npm run test, then compare it with npm run dev and the Next.js testing documentation example. Done means the documented Jest example runs successfully when a dependency published as an ES module is present in node_modules.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nextjs
- Domain
- testing-qa, web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100