<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>wafuwafu13</author_name>
  <author_url>https://blog.hatena.ne.jp/wafuwafu13/</author_url>
  <blog_title>経験は何よりも饒舌</blog_title>
  <blog_url>https://wafuwafu13.hatenadiary.com/</blog_url>
  <categories>
    <anon>Jest</anon>
    <anon>テスト</anon>
  </categories>
  <description>npqという、npmやyarnでインストールする際に安全確認をするライブラリがあり、そこで使われているaxiosをnode-fetchで代替するというissueがあったのでやってみた。github.com github.com置き換えるだけの簡単な作業かと思っていたが、テストを通すのが難しかった。 jest.mock や mockImplementation や jest.spyOnに対する理解が曖昧だったので、整理したいと思う。 コードはこのレポジトリにまとめた。 github.com まずは、単純な関数のモックから整理していきたい。 下のように、第2引数とランダムな値を足した値を返す関数が…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fwafuwafu13.hatenadiary.com%2Fentry%2F2021%2F03%2F01%2F121427&quot; title=&quot;Jest のモック関数を整理する - 経験は何よりも饒舌&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url>https://cdn-ak.f.st-hatena.com/images/fotolife/w/wafuwafu13/20210406/20210406122607.png</image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2021-03-01 12:14:27</published>
  <title>Jest のモック関数を整理する</title>
  <type>rich</type>
  <url>https://wafuwafu13.hatenadiary.com/entry/2021/03/01/121427</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
