LoginSignup
2
0

JestとTypeScriptでProperty 'toBeInTheDocument' does not exist on type 'Matchers<void, HTMLElement>'エラーが出る

Last updated at Posted at 2024-02-17

はじめに

よくみかけるエラーでしたが、結構苦戦したのでまとめます

問題

以下のエラーがVSCodeででました

image.png

Property 'toBeInTheDocument' does not exist on type 'JestMatchers<HTMLElement>'.ts(2339)
any

解決方法

tsconfigを修正します

image.png

CompilerOptionsに以下を追加することでVSCodeのエラーが消えました

    "types": ["node", "jest", "@testing-library/jest-dom"]

おわりに

更新まですこし時間がかかるので効いてないと勘違いもしました

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