# Mocking

Mocking is a testing technique where simulated objects or services replace real dependencies to create a controlled test environment. Mocks mimic the behavior of real components, returning predefined responses to specific inputs, which allows developers to test code in isolation without relying on external systems.

In API development, mocking is used at several levels. API mocking involves creating a simulated API server that returns predefined responses, allowing frontend developers to build against an API before the backend is implemented. Mock servers can be generated automatically from API specifications like OpenAPI documents. Tools such as Postman, WireMock, and Mockoon are commonly used for this purpose.

Mocking is valuable in API gateway testing. Teams can mock backend services to test gateway configurations -- such as routing rules, authentication logic, and rate limiting -- without deploying actual services. This enables faster development cycles and more reliable testing. In integration testing, mocking external APIs prevents tests from failing due to third-party service outages or rate limits.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.serverlessapigateway.com/glossary/m/mocking.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
