I don't know why ng test
is run successful, and npm run test
is failed
package.json
{
"name": "fe-patient",
"version": "0.0.1",
"author": "Ionic Framework",
"homepage": "https://ionicframework.com/",
"scripts": {
"commit": "git cz",
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
...
npm run test should do the same with ng test...
What i have tried and the issue still exists:
- npm cache clean --force
- rm -rf node_modules
- rm -rf package-lock.json
- npm install
- npm run test
Angular 12 , npm 6.14.8, ionic 5
CodePudding user response:
Finally find the root cause...
Current we haven't written any UT (spec files), so we delete all the spec files.
ng test
will show successful if there is 0 spec file,
npm run test
will give an error if there is 0 spec file.
Update Better solution:
Update config in karma.conf.js will also work:
failOnEmptyTestSuite: false,