运行一个测试文件 [英] Running a single test file

查看:60
本文介绍了运行一个测试文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以对单个文件而不是整个测试套件运行ng test?理想情况下,我想在编辑文件时获得最快的反馈循环,但是karma在每次保存时都执行整个套件,而当您建立足够大的测试套件时,这会有点慢. >


这不同于如何仅执行一个这个问题是关于angular-cli 的测试规范,它与运行单个规范有关.这是关于运行单个文件.该解决方案具有相同的Jasmine规格功能,但问题的性质略有不同.

解决方案

我发现Jasmine允许您在describeit方法前加上f前缀(以获取焦点?).因此,fdescribefit.如果您使用其中任何一种,业力将仅运行相关的测试.因此,要聚焦当前文件,您可以仅选择顶级describe并将其更改为fdescribe.为我的目的而工作.

Is there a way to run ng test for a single file instead of for the entire test suite? Ideally, I'd like to get the quickest possible feedback loop when I'm editing a file, but karma executes the whole suite on each save, which is a bit slow when you build up a big enough test suite.


This is different from How to execute only one test spec with angular-cli in that that question is about running an individual spec. This is about running an individual file. The solution involves the same Jasmine spec feature, but the nature of the question is slightly different.

解决方案

I discovered that Jasmine allows you to prefix describe and it methods with an f (for focus?). So, fdescribe and fit. If you use either of these, karma will only run the relevant tests. So, to focus the current file, you can just take the top level describe and change it to fdescribe. Works for my purposes.

这篇关于运行一个测试文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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