Company
Date Published
Author
Waweru Mwaura
Word count
2292
Language
English
Hacker News points
None

Summary

Contract testing ensures that different services communicate effectively and adhere to a predetermined set of rules, similar to fulfilling a contract. This tutorial demonstrates using the Joi library to create API contracts for testing an open-source API endpoint that monitors Bitcoin Price Index for various currencies, specifically focusing on testing the responses returned by the Coinbase API using a NodeJS application. By setting up a contract test environment and writing Joi contracts, users can validate API responses against defined schema contracts, identifying errors and inconsistencies. The tutorial also covers automating tests through a CI pipeline configuration using CircleCI, enabling efficient detection of changes in API responses and ensuring the application's reliability against external dependencies. The process involves setting up a NodeJS environment, installing dependencies, creating contract schemas, handling errors, and integrating with CircleCI to automate testing and ensure service stability.