October 2018
Intermediate to advanced
590 pages
15h 5m
English
There are two scenarios we need to cover in the test. One is a successful registration and the other is a failed registration. Our application behaves differently in these two scenarios. It is better that we use a separate test for each scenario.
In the test for the submitForm() method, we will isolate the method itself from its dependency, registrationService, by creating a mock of the service. In this way, we can define the behavior of the dependency and make sure it won't affect the test result. Using Jest, we will need to put the mocks in a folder named __mocks__ inside the same directory as the dependency. And the following are the paths of registrationService and its mock:
frontend/src/services/registration/index.js ...
Read now
Unlock full access