@lifeomic/test-tool-mockserver
v5.2.1
Published
[![npm](https://img.shields.io/npm/v/@lifeomic/test-tool-mockserver.svg)](https://www.npmjs.com/package/@lifeomic/test-tool-mockserver) [![Build Status](https://github.com/lifeomic/test-tools/actions/workflows/release.yaml/badge.svg)](https://github.com/l
Downloads
393
Readme
@lifeomic/test-tool-mockserver
MockServer Client
Some mockserver-client helpers.
import {
mockInvocation,
verifyInvocation,
} from '@lifeomic/test-tool-mockserver';
mockInvocation
Mocks the AWS Lambda service level calls. Very useful when combined with localstack invoking lambdas. The service level interactions are handled by the method call, and the consumer provides the lambda invocation request/response payload.
const functionName = 'my-function-name';
const expectedResponse = { verifyResponse: 'result' };
const expectedRequestBody = { verifyRequest: 'value' };
await mockInvocation(mockServerClient, functionName, expectedResponse, expectedRequestBody);
// Invoke so that we can retest verify after invocation
await lambdaV2.invoke({
FunctionName: functionName,
Payload: JSON.stringify(expectedRequestBody),
}).promise();
verifyInvocation
Verify that the lambda mock service was invoked with the expected body.
// Verifying one invocation should succeed now
await verifyInvocation(mockServerClient, functionName, expectedRequestBody, 1);