<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>kanezoh</author_name>
  <author_url>https://blog.hatena.ne.jp/kanezoh/</author_url>
  <blog_title>かねぞうサバイブ</blog_title>
  <blog_url>https://blog.kanezoh.com/</blog_url>
  <categories>
    <anon>jest</anon>
    <anon>React</anon>
    <anon>テスト</anon>
  </categories>
  <description>Reactのテストライブラリでreact-testing-libraryを使っているところは多いと思う。そこで、「ある要素が存在すること」をテストしたいことも多いだろう。そんな時は以下のように書けばいい。 it('画面に initial が表示されること', () =&gt; { const { getByText } = render(&lt;App /&gt;); expect(getByText('initial')).toBeTruthy() }); ただ、「ある要素が存在しないこと」をテストするにはどうすればいいのだろうか。例えばこんな風に書いてみる。 it('画面に initial が表示されること…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fblog.kanezoh.com%2Fentry%2F2023%2F02%2F12%2F165151&quot; title=&quot;react-testing-libraryで「要素が存在しないこと」をテストする方法 - かねぞうサバイブ&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></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2023-02-12 16:51:51</published>
  <title>react-testing-libraryで「要素が存在しないこと」をテストする方法</title>
  <type>rich</type>
  <url>https://blog.kanezoh.com/entry/2023/02/12/165151</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
