Gruntjs 试图排除GrunFile配置中的文件,但文件路径前缀正在破坏表达式

Gruntjs 试图排除GrunFile配置中的文件,但文件路径前缀正在破坏表达式,gruntjs,karma-runner,Gruntjs,Karma Runner,我正在使用一个karma任务设置grunt,该任务查找所有单元测试文件。我需要访问所有*.js文件和*.spec.js文件,但我想排除所有*.e2e.js文件。根据这些文档,我希望以下内容能够起作用(在karma.conf.js中): 然而,当我尝试运行我的grunt test任务时,它仍然尝试加载这些e2e.js测试,这些测试会中断,因为每个测试都引用了量角器,这让karma感到困惑。根据我的控制台,我看到的URL如下: userdirectory/repo/!app/mytest.e2e.j

我正在使用一个karma任务设置grunt,该任务查找所有单元测试文件。我需要访问所有
*.js
文件和
*.spec.js
文件,但我想排除所有
*.e2e.js
文件。根据这些文档,我希望以下内容能够起作用(在karma.conf.js中):

然而,当我尝试运行我的
grunt test
任务时,它仍然尝试加载这些
e2e.js
测试,这些测试会中断,因为每个测试都引用了量角器,这让karma感到困惑。根据我的控制台,我看到的URL如下:

userdirectory/repo/!app/mytest.e2e.js


看起来完整的文件路径(或者至少是其中的一部分)被预先添加到karma.conf.js中我提供的文件glob模式中。grunt是在加载karma任务之后才这样做的吗?

我的问题是karma没有使用与grunt相同的globber语法。根据karma的说法,您使用“文件”来显示您想要包括的内容,并使用
排除
来显示您想要排除的内容:

exclude
Type: Array
Default: []
Description: List of files/patterns to exclude from loaded files.
以下是我的解决方案:

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'
]

是否无法将e2e测试放在单独的文件夹中?这样,它们将更容易被排除,并包含在它们自己的配置文件中。@LudwigMagnusson当然可以,但这并不能帮助我找出为什么这不起作用。
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'
]