我正在根据请求进行 Jest 测试
describe("GET /user ", () => {
test("It should respond with a array of users", done => {
return request(url, (err, res, body) => {
if (err) {
console.log(err)
} else {
console.log("GET on " + url);
body = JSON.parse(body);
expect(body.length).toBeGreaterThan(0);
done();
}
})
})
});Run Code Online (Sandbox Code Playgroud)
这很奇怪,因为在终端中,jest 将 console.log 行显示为输出的一部分:
...test output...
console.log test/modules/user.test.js:18
GET on https://xpto/api/user
...more test output...
Run Code Online (Sandbox Code Playgroud)
我需要隐藏该行:
console.log test/modules/user.test.js:18
Run Code Online (Sandbox Code Playgroud)
如何在 Jest 输出中隐藏 console.log 行?
Jest具有此功能来记录输出到console方法的行。
在某些情况下,这可能会令人讨厌:
console.log _modules/log.js:37
? login.0 screenshot start
console.time _modules/init.js:409
login.0.screenshot: 0.33ms
console.time _modules/init.js:394
0 | login.0: 0.524ms
console.log _modules/log.js:37
? login.1 screenshot start
Run Code Online (Sandbox Code Playgroud)
知道如何关闭它吗?