简体   繁体   English

Karma-Jasmine单元测试语法

[英]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.

相关问题 使用 Karma-Jasmine 进行单元测试 mat-menu - Unit test mat-menu with Karma-Jasmine 如何使用 Angular 中的 Karma-Jasmine 对嵌套的 if 条件进行单元测试? - How to unit test a nested if condition in with Karma-Jasmine in Angular? 离子2业力茉莉花单元测试 - Ionic 2 karma-jasmine unit tesing 编写 Karma-Jasmine 单元测试用例时出现“错误:没有路由器提供程序” - “Error: No provider for router” while writing Karma-Jasmine unit test cases 如何使用Angular2中的karma-jasmine对ng2-translate进行单元测试 - How to unit test ng2-translate using karma-jasmine in Angular2 单击链接,Angular 2和业力茉莉花单元测试用例打开模态 - Angular 2 and karma-jasmine unit test case to open modal on click of link Karma-Jasmine for.sort() 中的单元测试故障排除 Angular 中的 function - Unit Testing Troubleshoot in Karma-Jasmine for .sort() function in Angular 如何为动态配置文件 JSON 编写 karma-Jasmine 测试 - How to write a karma-Jasmine test for a dynamic configuration file JSON Karma-Jasmine 如何在 angular 中测试一个路由器组件 - Karma-Jasmine How to test in angular a Router component Angular 4 错误:Karma-Jasmine 测试中没有 ChildrenOutletContexts 的提供者 - Angular 4 Error: No provider for ChildrenOutletContexts in Karma-Jasmine Test
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM