首页 > 解决方案 > 玩笑测试中过于冗长的日志记录

问题描述

➤ YN0000: [@bb/graph]:     console.log
➤ YN0000: [@bb/graph]:       info:     after all completed
➤ YN0000: [@bb/graph]: 
➤ YN0000: [@bb/graph]:       at Console.log (../.yarn/cache/winston-npm-3.3.3-3fa4527b42-8a9d69c642.zip/node_modules/winston/lib/winston/transports/console.js:79:23)

我得到了这个过于冗长的输出(主要是我不想看到这些console.log东西,只是info: after all completed在我的测试输出中。

我正在使用 yarn2、jest 和 winston,我不认为它是 winston,因为它不支持记录行号,而且当我在测试之外启动服务器时不会发生这种情况。我也不认为它是 yarn2 ,因为它发生在我运行时yarn workspace @bb/graph test,它不包含前缀。这让我猜这是开玩笑。这是我的配置。

module.exports = {
  preset: 'ts-jest',
  coverageDirectory: 'coverage',
  coverageReporters: [
    'text-summary',
  ],
  coverageThreshold: {
    global: {
      branches: 50,
      functions: 65,
      lines: 80,
      statements: 80,
    },
  },
  setupFiles: ['./jest.setup.js'],
  testEnvironment: 'node',
  testMatch: ['**/__tests__/**/*.ts', '**/*.test.ts'],
  testPathIgnorePatterns: ['/node_modules/', '/build/'],
};

其他一切都是默认值。

标签: node.jsjestjsyarnpkgwinstonyarnpkg-v2

解决方案


推荐阅读