Karma:从命令行运行单个测试文件 [英] Karma: Running a single test file from command line

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

问题描述



现在如果我想要这样做,我会发现类似的答案,但不完全是我想要的。用业力测试单个文件,我需要在有问题的文件上执行 fit() fdescribe()。 ..

然而,我所希望的是能够使用配置文件调用karma,并将其指向特定文件,所以我不需要需要修改文件,例如:

karma run --conf karma.conf.js --file / path / to / specific /test_file.js



是否可以这样做?或与任何帮手? (使用grunt或gulp?)

解决方案

首先,您需要使用
$ b启动karma服务器$ b

  karma start 

然后,您可以使用grep过滤特定的测试或描述块:

  karma run  -  --grep = testDescriptionFilter 


So, I've been looking all over for this, found "similar" answers here, but not exactly what I want.

Right now if I want to test a single file with karma, I need to do fit(), fdescribe() on the file in question...

However, what I do want is to be able to just call karma, with the config file, and direct it to a specific file, so I don't need to modify the file at all, ie:

karma run --conf karma.conf.js --file /path/to/specific/test_file.js

is it possible to do this? Or with any helper? (using grunt or gulp?)

解决方案

First you need to start karma server with

karma start

Then, you can use grep to filter a specific test or describe block:

karma run -- --grep=testDescriptionFilter

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

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