Before we integrate our new facade with the actual system, we should put it through its paces and thoroughly test it. So let’s develop a set of tests and helper elements for testing all of the operations registered in the facade. We’ll start off by creating a set of helper classes. One will test our dependencies, another will test how well the facade works with users, and the last one will contain a set of test users. All of these files will be placed in the folder /test/fixtures.
The file for testing dependencies will be called TestReferences.ts and will allow us to test how well the facade is able to work with the microservices it depends on. This file’s code is listed below:
Now, let’s create a file with a test client, which will help us test our user and session related operations. Place the code below into a file named TestRestClient.ts:
Lastly, define some test users in a file named TestUsers.ts, as shown below:
Now we can move on to the tests themselves. Create the following files in the folder test/operations:
BeaconsRoutesV1.test.ts - for testing business logic operations of the Beacons microservice:
SessionsRoutesV1.test.ts - for testing user and session related operations:
Run the tests using the following command:
Once all the tests pass successfully, you can move on to Step 7 - Running the facade - to learn how to deploy all of these microservices using Docker.