Skip to content

Commit

Permalink
Fix Jest test console errors
Browse files Browse the repository at this point in the history
There is a known Jest bug documented here:
facebook/create-react-app#11928 regarding
an "experimental feature jsx" that is not supported. Apply the
workaround here, as well as set the Jest test environment to
"jsdom" for React Testing Library to properly run.
  • Loading branch information
drake-smith committed Mar 20, 2022
1 parent 50a66b8 commit 5f54814
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"env": {
"test": { "presets": ["react-app"] }
}
}
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"test": "npm run test:types && npm run test:jest",
"test:jest": "jest",
"test:types": "tsc --noEmit",
"eject": "react-scripts eject",
"prepare": "husky install",
"lint": "eslint src --ext .js,.ts,.tsx",
Expand All @@ -32,6 +34,9 @@
"npm run lint"
]
},
"jest": {
"testEnvironment": "jsdom"
},
"eslintConfig": {
"extends": [
"react-app",
Expand Down

0 comments on commit 5f54814

Please sign in to comment.