3

I wrote above 500 unit test methods. when i give ng test command. it starting to test all the 500 methods.

If any test cases failed, it wont stop and still it continue to execute all methods. So i need wait more time to rerun the unit test again.

I know we can exist by doing ctr+c and again rerun the unit test by using ng test command. This way also taking too much time.

So is it possible to stop (not exist) the unit test, if any one of the test is failed?

Ramesh Rajendran
  • 37,412
  • 45
  • 153
  • 234
  • Possible duplicate of: [stop](https://stackoverflow.com/q/22119193/1265945) jasmine test after first expect fails. The answer is found inside that question over [here](https://stackoverflow.com/a/31809311/1265945). – Brampage Feb 09 '18 at 09:00
  • Possible duplicate of [Stop jasmine test after first expect fails](https://stackoverflow.com/questions/22119193/stop-jasmine-test-after-first-expect-fails) – Brampage Feb 09 '18 at 09:02

2 Answers2

1

If you want to exclude the file from the all test cases. try to add in the exclude section in the cli config file.

src/tsconfig.app.json: 

shown here:

{
  "compilerOptions": {
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [
      "es2016",
      "dom"
    ],
    "outDir": "../out-tsc/app",
    "target": "es5",
    "module": "es2015",
    "baseUrl": "",
    "types": []
  },
  "exclude": [
    "test.ts",
    "filename.spec.ts"
  ]
}
Overflowrun
  • 541
  • 3
  • 18
0

Another way is to use fdescribe in jasmine library. Its exactly same as the jasmine describe function except that by using this function karma (if you'r using karma) executed only fdescribe blocks and ignore all describe blocks, for example :

fdescribe('this block will executed' , async()=>{ 
 ....
 it('only this method will during tests', ()=>{
    expect(1).toEqual(1);
 });
...
describe('this block not executed' ()=>{
   .....
}

when tests finish you can simply repalce fdescribe function with describe

Ali Bigdeli
  • 1,286
  • 3
  • 17
  • 35