Mocking react-intl package for unit testing

Previously, I wrote about unit testing components which use react-intl package. If you did not inject an intl object to the component, it would throw errors while running tests. The solution was to create a factory method which wrapped the component with an IntlProvider and ref the component. This solution is handy if you are not using enzyme, otherwise since your mounted/shallowed component will be the IntlProvider it is going to be hard to manipulate the state and/or props of our component. 

Continue to read >>

Things you might need to know about Php

Lately I am spending some time with tests on hackerrank to improve my algorithm skills. This post will list all the nitty gritty stuff I've came accross with.

Continue to read >>

Unit testing i18n components

Today, while at work, I got crazy trying to figure out how to unit test properly components that are using react-intl. The test runner was constantly throwing the error:

Invariant Violation: [React Intl] Could not find required `intl` object. <IntlProvider> needs to exist in the component ancestry.

Although the error states pretty much the solution, it was a bit tricky to make things work properly. So I decided to blog about this.

Continue to read >>