在Jest中,Console.log语句根本没有输出任何内容

时间:2018-02-08 22:19:36

标签: jestjs console.log

在Jest中,

whenReady(responseParser.parseErroredResponse(response)) { failure => log.debug(s"$failure") failure mustBe a[SubmissionFailure] failure.message mustEqual "There is a syntax error in one of the queries in the AQuA input" failure.code mustEqual "90005" failure.names mustEqual Seq("Account", "AccountingPeriod", "NonExistent") failure.queries mustEqual Seq( "select Id from Account", "select Id from AccountingPeriod", "select non-existent from non-existent" ) } 语句根本没有输出任何内容。昨天这对我有用,突然之间,它今天不起作用了。我对配置进行了零更改,但没有安装任何更新。

我没有使用console.log选项。仍然看到这个问题。

9 个答案:

答案 0 :(得分:29)

根据对https://github.com/facebook/jest/issues/2441的评论,

尝试在package.json的jest选项中设置verbose:false(或将其删除)。

答案 1 :(得分:14)

Jest默认情况下不显示控制台日志消息。为了显示控制台日志消息,请在命令行上将silent选项设置为false

在命令行中设置--silent=false

npm run test -- --silent=false

答案 2 :(得分:13)

尝试像这样--watch --verbose false

一起使用这两个选项

答案 3 :(得分:8)

除了--verbose选项可能导致上述问题外,请注意--watch也可能导致此错误。

答案 4 :(得分:6)

检查package.json中的命令行标志,以查看其中没有--silent

答案 5 :(得分:2)

还要确保您的笑话配置没有silent: true。就我而言,我没有意识到其他人已将其添加到我们的配置中。

我在list of config options中看不到它,但是在the command line flag is documented here中看到了它。

答案 6 :(得分:0)

在我的情况下,问题是在需要模块时即在实际测试用例开始之前记录日志。从顶级LPSTR ComputerName[MAX_COMPUTERNAME_LENGTH + 1]; // is equivalent to: CHAR* ComputerName[MAX_COMPUTERNAME_LENGTH + 1]; // ^ 更改为在测试用例中使用import可以解决此问题。

答案 7 :(得分:0)

就我而言,问题是由[only]标志引起的

答案 8 :(得分:-2)

将我的文件从 index.test.js 重命名为 index.spec.js 对我有用。