vercel / vercel/next.js

`npm run test` fails with-jest-app using --watch flag.

Open
#69,236 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

examples
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: #40~22.04.3-Ubuntu SMP PREEMPT_DYNAMIC Tue Jul 30 17:30:19 UTC 2
  Available memory (MB): 64156
  Available CPU cores: 32
Binaries:
  Node: 20.9.0
  npm: 10.2.4
  Yarn: 1.22.22
  pnpm: 9.8.0
Relevant Packages:
  next: 14.2.6 // Latest available version is detected (14.2.6).
  eslint-config-next: N/A
  react: 18.3.1
  react-dom: 18.3.1
  typescript: 5.3.3
Next.js Config:
  output: N/A
Which example does this report relate to?

with-jest-app

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

The default with-jest-app example fails to run the tests and produces an error with no message. Example:

Determining test suites to run...

  ● Test suite failed to run

thrown: [Error]

I changed package.json to use a different test command. The default is as follows:

"scripts": {
  "test": "jest --watch",
},

I changed it to two alternative configurations, both which ran the tests successfully:

"scripts": {
  "test": "jest",
},
"scripts": {
  "test": "jest --watchAll",
},

The example should work out of the box, so either the error should be figured out so --watch works, or --watchAll should be used, or the flag should be removed.

Expected Behavior
npm run test

> test
> jest

 PASS  __tests__/index.test.tsx
 PASS  __tests__/snapshot.tsx
 PASS  app/counter.test.tsx
 PASS  app/page.test.tsx
 PASS  app/blog/[slug]/page.test.tsx
 PASS  app/utils/add.test.ts

Test Suites: 6 passed, 6 total
Tests:       6 passed, 6 total
Snapshots:   1 passed, 1 total
Time:        0.924 s, estimated 1 s
Ran all test suites.
To Reproduce

Clone the with-jest-app example project and run npm run test

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

Start in the with-jest-app example's package.json and reproduce the failure with npm run test, comparing the --watch and --watchAll commands. Use the listed test files, including tests/index.test.tsx and app/counter.test.tsx, to verify that the default command runs all six suites successfully without the empty error.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, next.js, react, typescript
Domain
testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.