This section contains code samples for testing asynchronous architectures using Typescript.
Asynchronous systems typically receive messages or events and immediately store them for future processing. Later, a secondary processing service may perform operations on the stored data. Processed data may then be sent as output to additional services or placed into another storage location. Below is a diagram illustrating a generic asynchronous pattern.
When testing asynchronous systems, you will establish event listeners that are only used for testing purposes. These event listeners will be configured to receive the output of your system under test (SUT). These test resources will be deployed to pre-production environments. If your production environment can tolerate the introduction of test data, you may decide to deploy these resources to production as well.
Your tests will establish a connection to the event listeners, and then perform polling actions against them with some reasonable timeout. The tests will send input data to the SUT. The SUT will process the data and send output to the event listener. The polling action will eventually retrieve the output data and examine it for the expected result.
Project | Description |
---|---|
Async Integration Test Sample | In this pattern, an AWS Lambda function is configured to be an event listener to receive the asynchronous System Under Test's output data. |
Testing a Stream-based Architecture | This project contains an example of testing a data processing system that processes records from an Amazon Kinesis Data Stream and stores the processed records in an Amazon DynamoDB table. |
Schema and Contract Testing | This project contains introductory examples of TypeScript unit tests demonstrating schema and contract testing. |