简体   繁体   中英

Use mocha, chai, chai-enzyme with react-create-app

I am using the react-create-app boilerplate for my react apps and its wonderful. but I am not much comfortable with how the jest test framework works and would like to use mocha, chai, chai-enzyme.

How could I change the test framework to the above mentioned stack?

Thanks.

If you want to use chai and chai-enzyme , you can use them perfectly fine with Jest. Even though we don't recommend them and encourage you to use the built-in assertion library, you may add third party assertion libraries like chai .

As for using a different test runner (such as Mocha), it is not really supported without ejecting ( npm run eject ). You could technically configure them right in the project but it would largely negate the benefits of Create React App since you would get an unsupported configuration and wouldn't be able to painlessly apply updates.

Once you eject, you should be able to use the official documentation of Mocha to set it up.

However I encourage you to report any problems you have with the existing stack as an issue. If you have specific problems with it we are happy to address them and improve it!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM