LoginSignup
2
0

More than 3 years have passed since last update.

Jestでconsoleをテスト結果に出さないようにする

Last updated at Posted at 2019-06-19

console.errorを環境によって出す〜みたいなことをしていたのですが
Jestのテスト結果にも出てきてしまい実害があるわけではないものの、どうも気持ち悪かったのです。

console.error('hogehoge')

(汚いスクショですみません)
スクリーンショット 2019-06-19 13.30.08.png

でもよくよく考えたら、ほかのmockと同様空の関数をmockすればよかったですね・・・。

console.error = jest.fn().mockImplementation(() => {})

ということで解決してテスト結果に不要なものがなくなってスッキリ。

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0