Newly created react app with typescript template crashing when running tests with coverage flag enabled
See original GitHub issueDescribe the bug
Running on a greenfield project created with create-react-app and typescript template the tests with the coverage flag doesn’t work. Running the test without coverage flag works fine.
Environment
Environment Info:
current version of create-react-app: 3.4.1
running from /Users/pperezdiez/.config/yarn/global/node_modules/create-react-app
System:
OS: macOS 10.15.5
CPU: (8) x64 Intel(R) Core(TM) i7-8569U CPU @ 2.80GHz
Binaries:
Node: 12.16.3 - ~/.nvm/versions/node/v12.16.3/bin/node
Yarn: 1.22.4 - /usr/local/bin/yarn
npm: 6.14.4 - ~/.nvm/versions/node/v12.16.3/bin/npm
Browsers:
Chrome: 85.0.4183.83
Firefox: 79.0
Safari: 13.1.1
npmPackages:
react: ^16.13.1 => 16.13.1
react-dom: ^16.13.1 => 16.13.1
react-scripts: 3.4.3 => 3.4.3
npmGlobalPackages:
create-react-app: Not Found
Steps to reproduce
- yarn create react-app my-first-app --template typescript
- Add to package.json a script to run tests with coverage:
"test:coverage": "react-scripts test -- --coverage --runInBand --watchAll=false",
- Run the coverage:
yarn test:coverage
Same can be done without yarn. I am adding yarn as it is how I created it so it is consistent with the info above.
Expected behavior
The tests are run properly when the coverage flag is enabled
Actual behavior
It crashes like if it wasn’t aware that it has to transpile typescript to run the tests.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:5
- Comments:7
Top Results From Across the Web
Running Tests | Create React App
Jest is a Node-based runner. This means that the tests always run in a Node environment and not in a real browser. This...
Read more >Why Code Coverage in react app is empty? Tried using npm ...
I have just created a new app using the latest create-react-app. I am trying to find the code coverage using npm run test...
Read more >Continuous integration for React applications using Jest and ...
Getting started. This project builds on the Redux Async Example app. Using this application will show how you would add tests to a...
Read more >Testing - React Native
In this guide, we will cover different, automated ways to ensure your app works as expected, ranging from static analysis to end-to-end tests....
Read more >Code Coverage for End-to-end Tests - Gleb Bahmutov
How to instrument application code and collect code coverage during Cypress E2E tests. Instrumenting the code as a pre-processor step; During ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is stale as there is no official answer but this is still happening.
I have detected that with react-scripts 4 this issue is solved, so if someone is still facing this I suggest to update. At least creating a project from scratch no longer fails when running tests with coverage flag.