SyntaxError: Identifier 'jest' has already been declared
create-react-appをejectしてyarn testを実行すると掲題のエラーが発生しました。
たまたま直せたので、直し方を書いておきます。
FAIL scripts/test.js
● Test suite failed to run
SyntaxError: Identifier 'jest' has already been declared
at Runtime._execModule (node_modules/jest-runtime/build/index.js:867:68)
jest
がすでに定義されているよ、というエラーです。
このエラーだけだと何が起きているかよくわからなかったんですが、 https://github.com/facebook/create-react-app/issues/1319 を読むと、scripts/test.js
もjestのテスト対象になっているせいで発生しているようでした。
jestの対象ディレクトリからscriptsを除外すれば直ります。
jest.config.js
module.exports = {
[...]
modulePathIgnorePatterns: ["<rootDir>/scripts/"],
[...]
Author And Source
この問題について(SyntaxError: Identifier 'jest' has already been declared), 我々は、より多くの情報をここで見つけました https://qiita.com/niwatori24/items/3b6612d257d1e92a1118著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .