[英]How Do I Run a Subset of Unit Tests Gulp-Angular with Karma?
I'm working on an AngularJS 1.4 project that was created from the Gulp-Angular yeoman generator. 我正在研究一个由Gulp-Angular yeoman发电机创建的AngularJS 1.4项目。 It has karma and gulp already configured so that when I run gulp test from the command line karma runs all of my *.spec.js files. 它已经配置了karma和gulp,这样当我从命令行运行gulp测试时 ,karma运行我所有的* .spec.js文件。 My problem is that it always run ALL of my spec.js files in the entire project. 我的问题是它总是在整个项目中运行我的所有spec.js文件。 I would like to just run one or two spec.js files- even better to be able to specify a folder and have it find all spec.js files recursively. 我想只运行一个或两个spec.js文件 - 更好的是能够指定一个文件夹并让它以递归方式查找所有spec.js文件。
I've tried just cd'ing down to a folder, but it still runs all tests. 我已经尝试过cd'ing到一个文件夹,但它仍然运行所有测试。
I've also tried editing this line in karma.conf.js: path.join(conf.paths.src, '/**/*.spec.js'), 我也尝试在karma.conf.js中编辑这一行:path.join(conf.paths.src,'/ / /。{。's''),
and this line in the gulp directory's unit-tests.js file: path.join(conf.paths.src, '/**/!(*.spec).js') 和gulp目录下的unit-tests.js文件中的这一行:path.join(conf.paths.src,'/ / /!(*。spec).js')
However, when I edit them I still get all the test suites in the whole entire project running! 但是,当我编辑它们时,我仍然可以在整个项目中运行所有测试套件! Ahh! 啊!
There must be a way to do what I'm trying to do. 必须有办法做我想做的事情。 Can anyone help me out with the correct approach here? 任何人都可以帮助我在这里采取正确的方法吗?
Karma is the test runner. Karma是试运行员。 Yeoman's gulp-angular generator uses Jasmine as the tester. Yeoman的gulp-angular发生器使用Jasmine作为测试器。
Search for a file jasmine.json. 搜索文件jasmine.json。
There is a "spec_dir"
and a "spec_files"
section that looks something like: 有一个"spec_dir"
和一个"spec_files"
部分,它看起来像:
"spec_dir": "./",
"spec_files": [
"**/*[sS]pec.js"
],
Modify it to fit your needs. 修改它以满足您的需求。 I'm guessing something along the line: 我在猜测一些事情:
"spec_dir": "./some_specific_path",
"spec_files": [
"**/*[sS]pec.js"
],
or if you want to do it incrementally from the root: 或者如果你想从根目录逐步进行:
"spec_dir": "./",
"spec_files": [
"some_specific_path_1/**/*[sS]pec.js",
"some_specific_path_2/**/*[sS]pec.js"
],
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.