简体   繁体   中英

Karma-Jasmine unit test syntax

Can you have multiple describe() in the same .spec.ts file? I am not talking about nested describe here.

describe('First describe', () => {
  it();
 })
describe('Second describe', () => {
it();
});

Is there any risk in doing this at any point in running the tests? I currently have 4 describe in my .spec to test different scenarios. Most of the time all tests pass. But some tests fail randomly even though the expected value is correct. Could the multiple describe be causing some issue? Is it better to make it nested? This is for an angular4 app

Yes, you can add multiple describe() in the .spec.ts because it is just javascript function. But for finding fails in your tests you need to debug it.

You can find it by following next link: https://jasmine.github.io/2.1/introduction.html#section-It's_Just_Functions

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM