如何只使用angular-cli执行一个测试规范 [英] How to execute only one test spec with angular-cli

查看:117
本文介绍了如何只使用angular-cli执行一个测试规范的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Angular-CLI(beta 20)构建Angular2项目。

I have Angular2 project build with Angular-CLI (beta 20).

有没有办法只针对一个选定的spec文件运行测试。

Is there a way to run test only against one selected spec file.

我以前有一个项目基于Angular2快速启动,我可以手动将规格添加到jasmine文件中。但我不知道如何设置这样的业力测试之外或如何将业力测试限制为使用angular-cli构建的某些文件。

I used to have a project based on Angular2 quick start, and I could manually add specs to jasmine file. But I don't know how to setup such an outside of karma testing or how to limit karma tests to some files with angular-cli builds.

推荐答案

你的每个 .spec.ts 文件都将其所有测试分组在 describe 块中,如下所示:

Each of your .spec.ts file have all its tests grouped in describe block like this:

describe('SomeComponent',()=> {...}

你可以通过在描述函数名称前加上 f

You can easily run just this single block, by prefixing the describe function name with f:

fdescribe('SomeComponent',()=> {...}

如果你有这样的功能,没有其他的描述块会运行。
顺便说一句。你可以做类似的事情 it => fit 并且还有一个黑名单版本 - x 。所以:

If you have such function, no other describe blocks will run. Btw. you can do similar thing with it => fit and there is also a "blacklist" version - x. So:


  • fdescribe 适合导致以这种方式标记的功能

  • xdescribe XIT 导致之外的所有功能都标记为运行

  • fdescribe and fit causes only functions marked this way to run
  • xdescribe and xit causes all but functions marked this way to run

这篇关于如何只使用angular-cli执行一个测试规范的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆