【问题标题】:Pass url parameter to qUnit test using Grunt使用 Grunt 将 url 参数传递给 qUnit 测试
【发布时间】:2014-12-09 20:51:35
【问题描述】:

我正在尝试使用来自 Grunt 的 qUnit 自动测试 JS 文件。我的 Grunt 任务如下:

  qunit: {
      a: 'dev/ca/js-tests/test1.html',
      b: 'dev/ca/js-tests/test2.html',
      c: 'dev/ca/js-tests/test2.html?status=approved'
  },

测试“a”和“b”运行良好,但是一旦我尝试在测试“c”中传递 URL 参数,我就会收到错误:

Running "qunit:c" (qunit) task
Warning: 0/0 assertions ran (0ms) Use --force to continue.

Aborted due to warnings.

使用“--force”无法解决。我的 JS 需要传入的参数 - 我如何从 Grunt 中完成此操作?

【问题讨论】:

  • 嗯...不确定,但您是否尝试过带有urls 集的完整options 对象? See this example on their Github page。这只是一个猜测,我不知道为什么查询字符串不能以简写形式工作。
  • 确实有效。谢谢 jakerella,将此作为答案,我会将其标记为正确。
  • 哈!我有点惊讶......我不知道为什么这两种格式应该有不同的解释。 :P

标签: gruntjs qunit


【解决方案1】:

添加这个作为我评论的答案,但老实说,不幸的是它应该是这样的......

看起来您必须使用完整的 options 对象和 urls 集。 See this example on their Github page。这是你的例子:

grunt.initConfig({
  qunit: {
    a: {
      options: {
        urls: [ 'http://localhost/dev/ca/js-tests/test1.html' ]
      }
    },
    b: {
      options: {
        urls: [ 'http://localhost/dev/ca/js-tests/test2.html' ]
      }
    },
    c: {
      options: {
        urls: [ 'http://localhost/dev/ca/js-tests/test2.html?status=approved' ]
      }
    }
  }
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-05-25
    • 2015-03-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多