question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

with-jest-app example doesn't work

See original GitHub issue

Verify canary release

  • I verified that the issue exists in Next.js canary release

Provide environment information

➜  with-jest git:(canary) npx --no-install next info

    Operating System:
      Platform: darwin
      Arch: x64
      Version: Darwin Kernel Version 20.6.0: Mon Aug 30 06:12:21 PDT 2021; root:xnu-7195.141.6~3/RELEASE_X86_64
    Binaries:
      Node: 18.2.0
      npm: 8.9.0
      Yarn: 1.22.11
      pnpm: N/A
    Relevant packages:
      next: 12.1.6
      react: 18.1.0
      react-dom: 18.1.0

warn  - Latest canary version not detected, detected: "12.1.6", newest: "12.1.7-canary.9".
        Please try the latest canary version (`npm install next@canary`) to confirm the issue still exists before creating a new issue.
        Read more - https://nextjs.org/docs/messages/opening-an-issue

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

After setting up the with-jest example from the documentation, yarn test consistently fails.

Expected Behavior

Whether using npx or directly cloning the repo and running yarn test, jest fails consistently. I’ve verified this on my work laptop as well.

The error is consistent: SyntaxError: Unexpected token '.'

Screen Shot 2022-05-20 at 6 14 02 PM

To Reproduce

Clone the repo or use npx create-next-app@latest --example with-jest with-jest-app following the documentation.

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
ijjkcommented, May 22, 2022

Hi, this example is working correctly against the latest canary of Next.js please update and give it a try!

Note: May need to run with --clearCache at first

1reaction
keeepariscommented, May 22, 2022

Test failes due to the fact that styles for index page located in pages folder. In order to pass the tests you should:

  1. Move index.module.css into src/styles folder;
  2. In index.tsx on 4th line change imports to -> @/styles/index.module.css
Read more comments on GitHub >

github_iconTop Results From Across the Web

Testing Next.js apps with Jest
First, we will make a change in the actual calculator application so that it does not work as expected on purpose. To do...
Read more >
Add the Jest Testing Framework to an Existing Next.js App
I have been using Next.js for a new project I am currently working on. Most of my Node.js experience working with web apps...
Read more >
Testing
Learn how to set up Next.js with three commonly used testing tools — Cypress, Playwright, Jest, and React Testing Library.
Read more >
Testing React Applications with Jest - Morioh
Learn how to test React applications with the Jest JavaScript testing framework. Jest is a JavaScript test runner maintained by Facebook.
Read more >
Next.js Cheat Sheet: Ultimate Guide to Next.js 2023 - Blog
In this article, you got to know what is Next.js in brief, Next.js Cheat Sheet, and how it helps in making modern React-based...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found