【问题标题】:Run a single spec with grunt-contrib-jasmine使用 grunt-contrib-jasmine 运行单个规范
【发布时间】:2013-07-15 21:50:27
【问题描述】:

当使用 grunt-contrib-jasmine 时,我将如何在命令行上指定要运行的单个规范文件?我的茉莉花部分看起来像:

jasmine: {
  myapp: {
    src: [ 'src/base.js', 'src/**/*.js' ]
  },
  options: {
    spec: [
      'spec/models/**/*.js',
      'spec/views/**/*.js'
    ]
  }
}

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

【问题讨论】:

    标签: javascript jasmine gruntjs


    【解决方案1】:

    有人使用--filter 命令行参数为您完成了这项工作,尽管它还没有被拉入master:

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

    文件名

    grunt jasmine --filter=foo 将运行文件名中包含 foo 的规范文件。

    文件夹

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

    通配符

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

    逗号分隔的过滤器

    grunt jasmine --filter=foo,bar 将运行文件名中包含 foo 或 bar 的规范文件。

    带空格的标志

    grunt jasmine --filter="foo bar" 将运行文件名中包含 foo bar 的规范文件。

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

    【讨论】:

    • 谢谢你。我在拉取请求中添加了一条评论,表示支持合并它。
    • 已合并!
    【解决方案2】:

    Chris Wren 在Advanced Grunt Tooling 上写了一篇博文,在Running individual test specs 部分下,他列出了一个示例,该示例允许命名您希望从命令行运行的规范。

    【讨论】:

    • 这些链接现已失效。我花了几分钟试图追踪原件,但它们似乎落后于身份验证:dev.chrisawren.com/posts/Advanced-Grunt-tooling
    • @internetross 感谢您的提醒并尝试恢复链接。我通过互联网档案找到了它们。再一次向他们捐款的好理由:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-05-30
    • 1970-01-01
    • 1970-01-01
    • 2013-02-06
    • 2013-10-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多