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:
/test/fixture/TestReferences.ts
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:
/test/fixture/TestRestClient.ts
Lastly, define some test users in a file named TestUsers.ts, as shown below:
/test/fixture/TestUsers.ts
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:
/test/operations/BeaconsRoutesV1.test.ts
SessionsRoutesV1.test.ts - for testing user and session related operations:
/test/operations/SessionsRoutesV1.test.ts
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.