Fixes at the end

The following are the fixes for this chapter. You can find the commit history on GitHub for each fix as follows:

  • Fixrename router: The name of the router is better if it excludes page and is lowercase. In this way, it is cleaner:
Figure 10.22: Fix—renaming router commit
  • Fixadd the missing test of services.registration.spec.js: The test of the registration service doesn't include verification for calling /api/registrations, which could fail to verify the behavior of the registration service because the register() method might even skip sending the request to the backend:
Figure 10.23: Fix—add the missing test of services.registration.spec.js commit
  • Fixerror handling on frontend: Different errors returned from the backend sometimes need to show the same message to users. It is better to have an error parser, otherwise known as an error translator, in the service to parse the error before forwarding it to the caller:
Figure 10.24: Fix—error handling on frontend commit
  • FixJest warning of duplicate manual mock: In the frontend, the mock file for the registration service and the one for the authentication service have the same name, index.js, as follows:
frontend/src/services/authentication/__mocks__/index.js
frontend/src/services/registration/__mocks__/index.js

Jest thinks they are mocks for the same JavaScript file and will ignore one of them. It is better to change services/authentication/index.js to services/authentication.js and services/registration/index.js to services/registration.js instead:

Figure 10.25: Fix—Jest warning of duplicate manual mock commit
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.107.85