@lifeomic/test-tool-mockserver
TypeScript icon, indicating that this package has built-in type declarations

5.2.1 • Public • Published

@lifeomic/test-tool-mockserver

npm Build Status

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);

Readme

Keywords

none

Package Sidebar

Install

npm i @lifeomic/test-tool-mockserver

Weekly Downloads

2

Version

5.2.1

License

MIT

Unpacked Size

14 kB

Total Files

8

Last publish

Collaborators

  • lifeomicdev
  • npm-lifeomicdev-github