使用grunt-contrib-jasmine运行单个规范

Rob*_*yon 10 javascript jasmine gruntjs

在命令行中,如何在使用grunt-contrib-jasmine时指定要运行的单个specfile?我的茉莉花部分看起来像:

jasmine: {
  myapp: {
    src: [ 'src/base.js', 'src/**/*.js' ]
  },
  options: {
    spec: [
      'spec/models/**/*.js',
      'spec/views/**/*.js'
    ]
  }
}
Run Code Online (Sandbox Code Playgroud)

我只是想运行测试spec/models/file1.js.

glo*_*tho 7

有人用--filter命令行参数为你做了这个,虽然它还没有被拉到master中:

https://github.com/gruntjs/grunt-contrib-jasmine/pull/70

文件名

grunt jasmine --filter=foo 将运行其文件名中包含foo的spec文件.

grunt jasmine --filter=/foo 将在名称中包含foo*的文件夹中运行spec文件.

通配符

grunt jasmine --filter=/*-bar 将运行位于文件夹*-bar中的任何内容

逗号分隔的过滤器

grunt jasmine --filter=foo,bar 将运行其文件名中包含foo或bar的spec文件.

标志与空间

grunt jasmine --filter="foo bar" 将运行其文件名中包含foo bar的spec文件.

grunt jasmine --filter="/foo bar" 将在名称中包含foo bar*的文件夹中运行spec文件.