【问题标题】:Logging from grunt-contrib-jasmine从 grunt-contrib-jasmine 记录
【发布时间】:2013-02-06 01:45:16
【问题描述】:

我正在使用 grunt-contrib-jasmine 来运行我的 javascript 规范。运行规范时如何将调试输出写入控制台,即如何获取

console.log("something");

在控制台中显示输出?我确实发现我可以通过运行获得输出:

 $ grunt jasmine --verbose

但这会打印出很多我不感兴趣的信息。我怎样才能看到来自 console.log 的输出?

【问题讨论】:

  • 其他设置是什么? display: 'short', summary: true - 我似乎无法让它记录任何内容。

标签: jasmine gruntjs


【解决方案1】:

不是解决方案,而是解决方法(有点)。 输入一个expect("something").toBe(null); 这会让jasmine 写出一条错误消息,例如:Expected 'something' to be null. 这样你就可以窥视对象(expect(element).toBe(null);

【讨论】:

    【解决方案2】:

    您也可以使用dump(variable)console.log(variable)Source is the excellent Year of Moo.

    【讨论】:

      【解决方案3】:

      使用console.info 而不是console.log

      【讨论】:

      • 别忘了console.debug()console.warn()console.error()
      • 为什么? console.log 是否更多地用于测试故意过滤掉的随机日志记录?
      • 恐怕我得到的结果与@sten-muchow 相同。没有任何控制台输出(日志、信息或错误)出现。
      • 啊,明白了。原来需要--debug grunt 选项而不是--verbose。 console.log、info 和 error 都会出现,尽管没有指明哪个是哪个。
      猜你喜欢
      • 2013-05-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-27
      • 1970-01-01
      • 2016-05-30
      • 2015-01-25
      相关资源
      最近更新 更多