[英]Karma-Jasmine unit test syntax
Can you have multiple describe()
in the same .spec.ts
file? 同一
.spec.ts
文件中可以有多个describe()
吗? I am not talking about nested describe
here. 我不是在这里谈论嵌套
describe
。
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. 我现在有4
describe
我.spec
来测试不同的场景。 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? 可以用多重
describe
引起某些问题吗? Is it better to make it nested? 嵌套起来更好吗? This is for an
angular4
app 这是针对
angular4
应用
Yes, you can add multiple describe()
in the .spec.ts
because it is just javascript function. 是的,您可以在
.spec.ts
添加多个describe()
,因为它只是javascript函数。 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 您可以通过以下链接找到它: https : //jasmine.github.io/2.1/introduction.html#section-It's_Just_Functions
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.