Enzyme expects an adapter to be configured

前端 未结 15 1578
太阳男子
太阳男子 2020-12-24 04:53

I created a new React application by create-react-app and I wanted to write a unit test to a component named \"MessageBox\" that I created in the application. This is the un

15条回答
  •  爱一瞬间的悲伤
    2020-12-24 05:26

    I faced the same error and for some reason React wasn't picking up setupTests.js file automatically.

    I created a new file called jest.config.js at the root directory and added

    { "jest": { "setupTestFrameworkScriptFile": "/path/to/your/file.js", } }
    

    After this, error disappeared.

    Note: Later on, I removed the jest.config.js file but it still works now.

    Not sure what was actually causing the problem though!

提交回复
热议问题