Home > Software design >  '● Test suite failed to run'
'● Test suite failed to run'

Time:05-31

I have used the following command :

npx create-react-app fresh-cra && cd fresh-cra

to create a fresh copy of a Create React App (CRA).

But when I run npm test as suggested in the instructions that follow
on the npx create-react-app command, it gives me an error :

● Test suite failed to run

Frustratingly, there is no additional information about the error.

'npm test' gives an error: Test suite failed to run.

^ click to enlarge

How can I work around this error?

After searching the internet for days, I finally found the question Jest from create-react-app not running on Windows which seems to report the exact same error, but for Windows 8.1.
(I am on Windows 10, version 21H2.)

Just as the asker of that question, I'm baffled. Not only by the error, but also by the time that has passed since then. Is it really true that after more than three years, the same error still prevails – without anyone in the Create React App team having fixed this bug? 1

Don't get me wrong. I'm a big fan of the create-react-app npm package.
For example, the eslint-config-react-app npm package has proven to be very useful.

But if this is a Windows-only bug, I honestly cannot help feeling a bit bullied for being on Windows.

Does anyone on Linux or macOS get this same error when running npm test
on a fresh Create React App?


Support for the experimental syntax 'jsx' isn't currently enabled

Since npm test didn't work, I felt inclined to run Jest directly, so I tried the npx jest command. 2

Support for the syntax 'jsx' isn't currently enabled.

But then I read this answer which – as I understand it – states that a Create React App is not configured out-of-the-box to run the jest command.
So that apparently is a dead-end alley that I don't want to walk down.

References


1 Or is it the Jest team that doesn't reach up to standards?

2 As did the asker of Jest from create-react-app not running on Windows.

CodePudding user response:

How can I work around this error?

Surprisingly, it's ridiculously simple.

In the package.json file, just replace

"test": "react-scripts test",

with

"test": "react-scripts test --watchAll",

When you now run npm test, expect to see :

The added '--watchAll' flag makes the error go away.

No error!

Reference

  • Related