> Markdown version of [/videos/710-contract-testing-how-do-you-tame-an-external-api-that-constantly-breaks-your-tests?t=492](https://www.wearedevelopers.com/videos/710-contract-testing-how-do-you-tame-an-external-api-that-constantly-breaks-your-tests?t=492). Every page supports `.md` or `Accept: text/markdown`. Links point to the HTML versions so they work for humans too. Agent guide: [/agents.md](https://www.wearedevelopers.com/agents.md). --- # Contract Testing - How do you tame an external API that constantly breaks your tests Are unpredictable external APIs constantly turning your integration pipelines red? Discover a three-tier contract testing strategy that completely decouples your frontend development from backend chaos. - **Speakers:** Vincent Hennig, Anupam Krishnamurthy - **Event:** World Congress 2023 - **Published:** September 27, 2023 - **Duration:** 26:02 - **URL:** https://www.wearedevelopers.com/videos/710-contract-testing-how-do-you-tame-an-external-api-that-constantly-breaks-your-tests ## Summary Front-end development teams often suffer from brittle workflows when external backend APIs unexpectedly change, turning integration pipelines red and halting productivity. To tame these agents of entropy, teams can implement a robust three-tier contract testing strategy. This begins with validating the API contract by cumulatively checking endpoint status codes, verifying response schemas, and finally ensuring specific data points required for frontend tests are present. Using a framework like Karate, these cumulative tests provide immediate clarity, pinpointing backend failures before front-end tests even begin to fail. However, an API contract is only as effective as its enforcement. Static documentation like Swagger often decays, leading to misaligned expectations and frustrating debugging sessions across chat applications. Instead, organizations should treat their test code as the ultimate contract. By sharing these automated tests directly with external partner teams, frontend developers establish clear behavioral expectations and empower backend engineers to debug issues locally. This collaborative approach replaces cryptic screenshots with reproducible data, dramatically reducing the time it takes to recover from major API overhauls. To completely decouple frontend development from unstable external APIs, teams can simulate the contract using a mock server intermediary. Acting as a buffer, a mock server shields the local development environment from sudden backend breakages, allowing seamless feature creation even when the live API is down. To solve the persistent challenge of keeping mocked data in sync with reality, developers can execute their existing contract tests against both the live API and the mock server simultaneously. Any discrepancy instantly flags out-of-sync mocked endpoints, ensuring the simulation remains a highly reliable reflection of the production environment. **Keywords:** contract testing, external API integrations, karate framework, API schema validation, mock server implementation, code as contract, API documentation decay, frontend test reliability, backend dependency management, cross-team debugging, mock data synchronization, API endpoint behavior, swagger documentation limitations, test data configuration ## Chapters 1. **Impact of external API changes on frontend tests** (00:03) — How unpredictable backend updates break frontend tests and cause severe development delays. 1. **Validating API contracts at three different levels** (04:13) — Building robust API validation requires checking endpoint status, response schema, and specific data formats. 1. **Implementing API validation tests using the Karate framework** (05:38) — Writing cumulative API tests ensures validation of schemas and specific data using external JSON files. 1. **Mapping frontend dependencies to API contract tests** (08:12) — Linking frontend tests to corresponding API data contracts speeds up failure analysis and debugging. 1. **Enforcing API contracts by sharing tests with partners** (09:09) — Replacing static API documentation with executable code tests allows partner teams to debug independently. 1. **Simulating API contracts using a mock server** (12:29) — Placing a mock server between the dev system and external APIs increases development stability. 1. **Building and syncing a mock server with Karate** (18:16) — Creating a local mock server guarantees that test data stays synchronized with actual external APIs. 1. **Contract testing summary and audience Q&A session** (21:59) — Implementing contract testing techniques prevents flaky tests and simplifies cross-team API integrations. ## Related Moments - [Discovering risk models and implementing contract testing tools](https://www.wearedevelopers.com/videos/467-quality-strategy-with-a-side-of-swiss-cheese) (from "Quality Strategy with a side of Swiss Cheese") - [Applying test-driven principles to APIs](https://www.wearedevelopers.com/videos/222-test-driven-development-with-javascript) (from "Test Driven Development with JavaScript") - [Managing distributed API endpoints using consumer-driven contract testing](https://www.wearedevelopers.com/videos/402-one-click-to-production-test-and-automate-your-application) (from "One-click-to-production: Test and automate your application") - [Clarifying the purpose of mock integration coding sessions](https://www.wearedevelopers.com/videos/503-why-pair-programming-is-the-best-usability-testing-tool-for-developer-focused-products) (from "Why pair programming is the best usability testing tool for developer focused products?") - [Limiting API mocking boundaries in software integration tests](https://www.wearedevelopers.com/videos/415-building-software-that-scales-with-typescript) (from "Building software that scales with Typescript") - [Preventing integration failures using contract and load testing](https://www.wearedevelopers.com/videos/1435-trunk-based-development-at-scale-real-world-insights-from-a-high-traffic-luxury-e-commerce-platform) (from "Trunk-Based Development at Scale: Real-World Insights from a High-Traffic Luxury E-Commerce Platform") ## Related Articles - [The CAMARA Project: How Telcos Collaborating Improves Developer Experience](https://www.wearedevelopers.com/magazine/671-the-camara-project-how-telcos-collaborating-improves-developer-experience) - [Liuba Gonta and Yuliya Khadasevic - GitHub Copilot Beyond the Basics - 10 Ways to Elevate Your Coding](https://www.wearedevelopers.com/magazine/490-liuba-gonta-and-yuliya-khadasevic-github-copilot-beyond-the-basics-10-ways-to-elevate-your-coding) - [Navigating the AI Shift](https://www.wearedevelopers.com/magazine/629-navigating-the-ai-shift) - [Dev Digest 121 - AI goes offline](https://www.wearedevelopers.com/magazine/456-dev-digest-121-ai-goes-offline) ## Related Jobs - [Senior AI Frontend Engineer](https://www.wearedevelopers.com/jobs/ext/2552851-senior-ai-frontend-engineer) at **TeamViewer Germany GmbH,** - [Senior Fullstack AI Engineer (React, Java)](https://www.wearedevelopers.com/jobs/ext/2618728-senior-fullstack-ai-engineer-react-java) at **TeamViewer Germany GmbH,** - [Bank Platform Transformation - Test Execution Leader - Sr Associate](https://www.wearedevelopers.com/jobs/ext/2407777-bank-platform-transformation-test-execution-leader-sr-associate) at **PwC** - [Bank Platform Transformation - Test Execution Leader - Sr Associate](https://www.wearedevelopers.com/jobs/ext/2391699-bank-platform-transformation-test-execution-leader-sr-associate) at **PwC** - [Bank Platform Transformation - Test Execution Leader - Sr Associate](https://www.wearedevelopers.com/jobs/ext/2548873-bank-platform-transformation-test-execution-leader-sr-associate) at **PwC** - [Bank Platform Transformation - Test Execution Leader - Sr Associate](https://www.wearedevelopers.com/jobs/ext/2619436-bank-platform-transformation-test-execution-leader-sr-associate) at **PwC**