13

I would like to configure npm test in my server. when I run npm test, it invokes react-scripts test which triggers a prompt window ( attached screen ). How do I avoid the prompt and run all testcases in the server.

"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"lint": "./node_modules/.bin/eslint ."
},

enter image description here

kulls
  • 845
  • 2
  • 12
  • 37

4 Answers4

35

To run all the tests, use "test": "react-scripts test --watchAll=false"

Anant_Kumar
  • 764
  • 1
  • 7
  • 23
Riya Adhikari
  • 367
  • 3
  • 7
4

If you pass CI=true, it will run once without setting up that prompt as described at https://create-react-app.dev/docs/running-tests/#linux-macos-bash:

CI=true npm test

Ben Creasy
  • 3,825
  • 4
  • 40
  • 50
2

When you want to run all tests you can use npm test --watchAll

Maciej Trojniarz
  • 702
  • 4
  • 14
  • 1
    --watchAll looking for changes in the script and it's keep spinning. Is there any other argument that avoid prompt and run all testfiles ? – kulls Sep 17 '19 at 06:23
  • ReactScripts tests all uncommited files in git. What do you want to achieve? Run all of the tests even if something not has been changed? `npm test` as well goes into watch mode – Maciej Trojniarz Sep 17 '19 at 06:49
-1

You can just update your package.json and in the scripts section update the test one with just "test": "jest"

It should run every test file that it can find in your project

Alpe89
  • 299
  • 2
  • 11
  • It's not that simple, because CRA programatically sets config you may be relying on: https://stackoverflow.com/a/62861130/3001761 – jonrsharpe Oct 11 '21 at 06:44