LoginSignup
2
1

react-testing-libraryでSyntaxError: Private field '#root' must be declared in an enclosing classエラーがでる

Posted at

はじめに

jestの導入でエラーが出たのでまとめます

問題

テストを実行すると以下のエラーが出ました

   /home/watanabejin/workspace/sin-simple-study/src/App.css:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){#root {
                                                                                     ^

    SyntaxError: Private field '#root' must be declared in an enclosing class

解決方法

jest.config.jsに以下の設定を追加しました

jest.config.js
export default {
  (省略)
  moduleNameMapper: {
    "\\.(css|less)$": "identity-obj-proxy",
  }
}

おわりに

よくわかっていない設定で消していたのでなるほどとなりました

2
1
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
1