ten*_*gen 4 gruntjs karma-runner
我正在设置一个寻找所有单元测试文件的业力任务的咕噜声.我需要访问所有*.js文件和*.spec.js文件,但我想排除所有*.e2e.js文件.根据节点glob文档,我希望以下工作(在karma.conf.js中):
files: [
'vendor/angular/angular.js',
'vendor/angular-mocks/angular-mocks.js',
'vendor/angular-resource/angular-resource.js',
'app/**/*.js',
'!app/**/*.e2e.js'
],
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试运行我的grunt test任务时,它仍然会尝试加载这些e2e.js测试,因为每个测试都引用了量角器,因此业力会被混淆.根据我的控制台,我看到URL是这样的:
userdirectory/repo/!app/mytest.e2e.js
似乎完整的文件路径(或至少其中一些)正在预先添加到我在karma.conf.js中提供的文件glob模式中.在加载业力任务之后,咕噜咕噜咕噜咕噜吗?
我的问题是,人缘也不能使用相同的通配符处理语法咕噜.根据karma的文档,您可以使用"文件"来显示要包含的内容,并exclude显示要排除的内容:
exclude
Type: Array
Default: []
Description: List of files/patterns to exclude from loaded files.
Run Code Online (Sandbox Code Playgroud)
这是我的修复:
files : [
// libraries / vendor files needed to test souce code
'vendor/angular/angular.js',
'vendor/angular/angular-route.js',
'vendor/angular/angular-mocks.js',
'vendor/require/*.js',
// all souce .js files, as well as all .spec.js test files
'app/modules/**/*.js'
],
exclude : [
// exclude all *.e2e.js end to end test files from being included
// - Karma will break when trying to load protractor
'app/modules/**/*.e2e.js'
]
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1921 次 |
| 最近记录: |