【问题标题】:How to turn off strongloop loopback-testing console logging?如何关闭 strongloop 环回测试控制台日志记录?
【发布时间】:2015-06-25 16:10:25
【问题描述】:

我有一个非常简单的 API 测试用例,使用 loopback-testing 模块完成。

lt = require('loopback-testing')
assert = require('assert')

describe '/profile', ->
  lt.beforeEach.withApp app

  lt.describe.whenCalledRemotely 'GET', '/api/profiles/ping', { data: 'test' }, ->
    lt.it.shouldBeAllowed()

    it 'should have statusCode 200', ->
      assert.equal @res.statusCode, 200

    it 'should have pong response', ->
      assert.equal @res.body.pong, 'test'

作为测试的结果,我在系统控制台上打印出这样的行:

 /profile
    GET /api/profiles/ping
GET /api/profiles/ping 200 50.639 ms - 15
      ✓ should be allowed
GET /api/profiles/ping 200 8.026 ms - 15
      ✓ should have statusCode 200
GET /api/profiles/ping 200 3.633 ms - 15
      ✓ should have pong response

有没有办法通过环回测试模块关闭将这些行写入系统控制台?这简直是​​破坏了我的 mocha 报告概述。

【问题讨论】:

    标签: javascript node.js loopbackjs strongloop


    【解决方案1】:

    您的应用程序中是否配置了任何日志记录中间件?额外的行看起来像morgan 生成的 HTTP 访问日志。

    运行测试时,您需要禁用应用程序中的任何 HTTP 日志记录中间件。相关说明取决于您如何配置此中间件,能否请您扩展您的问题并描述您的应用设置?

    【讨论】:

      猜你喜欢
      • 2016-09-07
      • 1970-01-01
      • 1970-01-01
      • 2012-05-29
      • 1970-01-01
      • 1970-01-01
      • 2018-10-28
      • 2021-06-01
      • 2017-03-31
      相关资源
      最近更新 更多