Overview¶
SmartMock.io is a Mock-As-A-Service solution. It provides tools that allow you to set up, manage, and troubleshoot your HTTP protocol API mocks in the cloud. This frees you up to focus on the logic of your mocks , as you don't have to think about boilerplate code, infrastructure, hosting, and hardware maintenance. Changes made in your mocks are immediately available for mock clients; no more waiting for time-consuming deployments of self-hosted mock services. SmartMock.io supports a broad spectrum of use cases that allow for the mocking of not only simple, static services but also complicated, dynamic ones.
Workspace¶
The top-level concept of SmartMock.io is a workspace. Every workspace is identified by a unique URL you'll use to send requests to your mocks. We encourage you to treat a workspace as a contained environment for a single service/API/application you'd like to simulate. This approach simplifies the management of workspaces and mocks. You may, however, merge many services/APIs into individual Workspace if required.
Mocks¶
The workspace contains one or more mocks, which basically match HTTP requests, render the response, and return that response to the client. Generally, a mock is the equivalent of an HTTP endpoint for an API you'd like to simulate and is usually identified by the HTTP method and path. In some use cases, for the same HTTP method / path pair, you may need more than one mock, which may return different responses based on other matching criteria.
Request Matching¶
Matching of requests is performed using a rich set of matchers that you may use for any HTTP field (method, path, header, query parameter, body).
See HTTP Request Matching section for more information.
Mock Types¶
Depending on the complexity of your use case, a mock may render a static, template or dynamic response
Static Mock¶
The simplest type of mock is a static mock. It returns a static string value (JSON, XML, plain text, etc.) any time an HTTP request fits certain mock matching rules. Static mocks cover the majority of our clients' use cases and do not need any coding skills. See Static Mock section for more information.
Template Mock¶
If you need mock responses which are not static (for example, containing random data or data retrieved from the request) but you don't want to write Javascript code, you may utilize a template mock. This type of mock uses Handlebars notation and provides some helpers that address an extensive set of use cases. See Template Mock section for more information about the request model, available helpers and examples.
Dynamic Mock¶
The most flexible type of mock is the dynamic mock. It's purely Javascript code that sets response status, headers, and body. You may use all features of Javascript (ES2015) and a rich set of libraries is provided by SmartMock.io (faker, lodash, moment, and others). SmartMock.io also provides a dedicated AP,I which represents an HTTP request, response and state so you can access these objects and set HTTP response fields (status, headers, body) to whatever you need. See Dynamic Mock section for more about information supported libraries, API documentation and examples.
Proxy Mocks¶
Proxy mocks allow for selective forwarding of the original HTTP requests to other services (for instance, real ones). Use proxy HTTP service mocks in conjunction with other types of mocks or response delay feature within the single workspace to simulate the behaviors that are impossible or difficult to generate on-demand with real services like long response times, specific error codes, malformed or incorrect responses, connection errors. See Proxy Mock section for more information.
State¶
Template and dynamic mocks may utilize state, which is essentially a workspace-scoped container for data. Adopting state in your template or dynamic mock enables you to simulate data persistence or a user session. In other words, you may share some data between mocks in the same workspace. See the Stateful responses section for more information about state and how to use it.
Team Work¶
SmartMock.io supports collaboration in your team. Workspaces may be shared with other team members or your business partners. This increases productivity since anyone in your team may create, modify, or troubleshoot mocks.