Comments (3)
That's odd. It seems to be working for me and CI is passing. Are you on the latest version?
from testing-react-apps.
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.
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)
- Typo in the sidebar on epicreact.dev HOT 4
- Incorrect titles and videos in 'Form Testing' section HOT 2
- Obsolete information about `jest.config.js` HOT 3
- [Exercise - 6] Have a different test for checking spinner HOT 1
- Exercice 6: use waitForElementToBeRemoved instead of manual await HOT 2
- init
- setup fails HOT 10
- Error when npm start HOT 10
- Changelog HOT 1
- JS file extension references in markdown instructions HOT 2
- Link broken in exercise 6 MD file HOT 1
- Error running tests HOT 2
- Overrides don't work the same with test-data-bot as previous extra credit HOT 1
- Cannot render Counter with createRoot HOT 1
- Exercise 01 is updated to React 18 but lacks instructions HOT 1
- Exercise 03 - Trigger click event using userEvent doesn't work HOT 1
- Need to downgrade `npm` in order to setup the project HOT 1
- Mocking Browser APIs and Modules Inconsistency HOT 3
- Excercise 05 is using msw 1.0 (rest). I think we should update to 2.0 (http) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from testing-react-apps.