Basic mock of AWS CodePipeline API, which can be used with the AWS SDK, curl
etc.
Start the mock server:
imposter up
Set the endpoint
configuration property in the AWS SDK to http://localhost:8080
, for example:
const client = new CodePipelineClient({
endpoint: 'http://localhost:8080',
// ...
});
For more details, see the Getting Started section.
Install Imposter CLI.
If using Homebrew:
brew tap gatehill/imposter
brew install imposter
Other installation options are available.
Start the mock server:
imposter up
When using the AWS SDK, set the endpoint
configuration property when creating the client:
const client = new CodePipelineClient({
endpoint: 'http://localhost:8080',
// ...
});
// list pipelines
const pipelines = await client.send(new ListPipelinesCommand({}));
// list pipeline executions
const executions = await client.send(new ListPipelineExecutionsCommand({
pipelineName: 'my-pipeline',
}));
// get a pipeline execution
const execution = await client.send(new GetPipelineExecutionCommand({
pipelineName: 'my-pipeline',
pipelineExecutionId: 'my-execution-id',
}));
The mock can also be started using the imposter-js library:
const { mocks } = require('@imposter-js/imposter');
// path to directory containing codepipeline-config.yaml
const configDir = __dirname;
// start a mock on a free port
const mock = await mocks.start(configDir);
// use the mock endpoint in your tests
const client = new CodePipelineClient({
endpoint: mock.baseUrl(),
// ...
});