问题描述
我使用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
andfit
causes only functions marked this way to runxdescribe
andxit
causes all but functions marked this way to run
这篇关于如何只使用angular-cli执行一个测试规范的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!