Set up Enzyme, expect, and mocha for Unit Testing

preview_player
Показать описание

We'll walk through setting up tooling for testing React components. AirBnb's Enzyme for shallow rendering, expect for assertions and spies, and mocha as our test runner. Then we will write our first unit test to make sure that our tooling is all set up and we can run tests via mocha.
Рекомендации по теме
Комментарии
Автор

Awesome video. Thanks! How do you deal with resolving absolute import statements? For example, import Example from 'components/Example' rather than the relative pathing and combining that with Mocha + Webpack? Mocha doesn't recognize the imports which are being handled by Webpack's configuration.

ConAntonakos
Автор

a test helper file is not required? in which you set jsDOM settings such as global.window etc.

usasikh