Getting started
There are many ways to run Imposter. There are two categories: run a standalone server, or embed it within unit/integration tests.
Standalone mock server
- Using the command line client - see Imposter CLI
- As a Docker container - see Imposter Docker container
- As a Lambda function in AWS - see Imposter AWS Lambda
- As a JAR file on the JVM - see Imposter JAR file
Embed in unit/integration tests
- Embed within your Java/Kotlin/Scala/JVM unit tests - see JVM bindings
- Embed within your JavaScript/Node.js unit tests - see JavaScript bindings
Choosing an approach
If you are looking for a quick local development solution, use the CLI.
If you want to run Imposter as a standalone mock server, you can run it as a Docker container. If Docker isn't your thing, or you want to build Imposter yourself, you can use it as a standalone JAR file. Standalone servers are often useful when you require long-lived mock instances.
You can also use it as a mock server for your unit tests on the JVM or Node.js, starting it before your tests, providing synthetic responses to your unit under test. Embedded instances tend to be short-lived and exist only for the duration of your test execution.
Examples
Let's assume your configuration is in a folder named config
.
CLI example:
imposter up ./config -p 8080
Docker example:
docker run -ti -p 8080:8080 -v $PWD/config:/opt/imposter/config outofcoffee/imposter
Standalone Java example:
java -jar ./imposter.jar --configDir ./config
Your mock server is now running!
These examples start a mock server using the simple REST plugin, serving responses based on the configuration files inside the
config
folder. You can hit the URL http://localhost:8080/example to see the mock response.
What's next
Learn how to use Imposter with the Configuration guide.