This package has been deprecated

Author message:

Replaced by https://www.npmjs.com/package/@jurijzahn8019/aws-promise-jest-mock

aws-promise-jest-mock
TypeScript icon, indicating that this package has built-in type declarations

1.1.3 • Public • Published

aws-promise-jest-mock

Build Status Coverage Status GitHub npm

simple libraray for jest-tested projects to create jest mock for js aws-sdk .promise() calls

WHY

i was tired to copy-paste my mock helpers across repos

install

npm i -D aws-promise-jest-mock

usage

// code file

export function foo() {
  return new SecretsManager().getSecretValue({ SecretId: "bar-baz" }).promise();
}

// spec file
import { SecretsManager } from "aws-sdk";
import { on, infer } from "aws-promise-jest-mock";
import { foo } from "./code.ts";

jest.mock("aws-sdk");

describe("aws-mock", () => {
  it("Should succeed", async () => {
    const m = on(SecretsManager)
      .mock("getSecretValue", infer)
      .resolve({ SecretString: "foo-bar" });

    const res = foo();

    await expect(res).resolves.toMatchSnapshot("Result");
    expect(m.mock).toHaveBeenCalledTimes(1);
  });

  it("Should fail", async () => {
    const m = on(SecretsManager)
      .mock("getSecretValue", infer)
      .reject("foo-baz");

    const res = foo();

    await expect(res).rejects.toMatchSnapshot("Result");
    expect(m.mock).toHaveBeenCalledTimes(1);
  });
});

Changelog

Changelog.

License

MIT Lizenz

Package Sidebar

Install

npm i aws-promise-jest-mock

Weekly Downloads

2

Version

1.1.3

License

MIT

Unpacked Size

50 kB

Total Files

9

Last publish

Collaborators

  • jurijzahn8019