首页 > 解决方案 > 如何将 mocha 错误符号更改为自定义字符串

问题描述

我正在尝试更改 mocha 的默认输出以测试成功和失败。我试过这个,它只适用于 ok 符号,但 err 没有变化

//.mocharc.js
const { symbols } = require('mocha/lib/reporters/base');

symbols.ok = '[PASS]'
symbols.err = '[FAIL]';
App
    sayHello
      [PASS] test sayHello should return hello
      [PASS] test sayHello return type is string
    returnNumber
      [PASS] test returnNumber return 10
      1) test returnNumber return type is number
    plusFive
      [PASS] test plusFive greater than 5
      [PASS] test plusFive return type is number
    myAbs
      [PASS] test myAbs return absolute number
      [PASS] test myAbs return type is number


  7 passing (20ms)
  1 failing

知道如何更改错误吗?

标签: mocha.js

解决方案


推荐阅读