October 2018
Intermediate to advanced
590 pages
15h 5m
English
Before writing the test code, let's talk about the behavior of the registrationService.register() method so that we can decide what to test. Essentially, this method will send an HTTP POST request to the backend and then hand the result back to its caller. The dependency of this method is axios, which needs to be mocked so that we can isolate the register() method and test its logic without being affected by the dependency.
Let's install axios and moxios, which mocks axios requests, with the following commands:
npm install axios --save npm install moxios --save-dev
Once it is done, let's create frontend/test/unit/services.registration.spec.js, which looks like the following:
1. import moxios from 'moxios'2. import ...
Read now
Unlock full access