Giter VIP home page Giter VIP logo

Comments (3)

kentcdodds avatar kentcdodds commented on May 20, 2024

That's odd. It seems to be working for me and CI is passing. Are you on the latest version?

from testing-react-apps.

rh569 avatar rh569 commented on May 20, 2024

I'm on main and am up to date with the remote.

Tested after clearing out node_modules/ and build/, pulling again just to be certain, and re-running npm setup --silent.

I can also repro this with the final version of the test file - causing it to fail by changing the password error message in the msw handler, then pressing 'u' to update the snapshot. (stacktrace included this time)

 FAIL  src/__tests__/final/05.extra-3.js
  ● Test suite failed to run

    SyntaxError: <path-to>/testing-react-apps/src/__tests__/final/05.extra-3.js: Support for the experimental syntax 'jsx' isn't currently enabled (26:10):

      24 |
      25 | test(`logging in displays the user's username`, async () => {
    > 26 |   render(<Login />)
         |          ^
      27 |   const {username, password} = buildLoginForm()
      28 |
      29 |   await userEvent.type(screen.getByLabelText(/username/i), username)

    Add @babel/preset-react (https://github.com/babel/babel/tree/main/packages/babel-preset-react) to the 'presets' section of your Babel config to enable transformation.
    If you want to leave it as-is, add @babel/plugin-syntax-jsx (https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-jsx) to the 'plugins' section to enable parsing.

      at instantiate (node_modules/@babel/parser/src/parse-error/credentials.js:61:22)
      at toParseError (node_modules/@babel/parser/src/parse-error.js:58:12)
      at Parser.raise (node_modules/@babel/parser/src/tokenizer/index.js:1736:19)
      at Parser.expectOnePlugin (node_modules/@babel/parser/src/tokenizer/index.js:1800:18)
      at Parser.parseExprAtom (node_modules/@babel/parser/src/parser/expression.js:1239:16)
      at Parser.parseExprSubscripts (node_modules/@babel/parser/src/parser/expression.js:684:23)
      at Parser.parseUpdate (node_modules/@babel/parser/src/parser/expression.js:663:21)
      at Parser.parseMaybeUnary (node_modules/@babel/parser/src/parser/expression.js:632:23)
      at Parser.parseMaybeUnaryOrPrivate (node_modules/@babel/parser/src/parser/expression.js:384:14)
      at Parser.parseExprOps (node_modules/@babel/parser/src/parser/expression.js:394:23)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        4.699 s
Ran all test suites matching /src\/__tests__\/final\/05\.extra-3\.js/i.

I was on node: 16.13.0 and npm: 8.1.4, but have since also reproduced on the latest stable 16 and 14.

from testing-react-apps.

kentcdodds avatar kentcdodds commented on May 20, 2024

Ah, I see what's going on. So it's updating the snapshot that is causing the issue. The problem is that jest can't find our babel config (because it's hidden in react-scripts). Adding @babel/preset-react to the package.json works so that's what I've done. Thanks!

from testing-react-apps.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.