Gathering detailed insights and metrics for @jurijzahn8019/aws-promise-jest-mock
Gathering detailed insights and metrics for @jurijzahn8019/aws-promise-jest-mock
Gathering detailed insights and metrics for @jurijzahn8019/aws-promise-jest-mock
Gathering detailed insights and metrics for @jurijzahn8019/aws-promise-jest-mock
npm install @jurijzahn8019/aws-promise-jest-mock
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
9 Stars
2,304 Commits
1 Forks
4 Watching
18 Branches
4 Contributors
Updated on 12 Jan 2024
TypeScript (70.14%)
JavaScript (29.47%)
Shell (0.39%)
Cumulative downloads
Total Downloads
Last day
519.6%
1,611
Compared to previous day
Last week
117.3%
3,160
Compared to previous week
Last month
144.5%
7,084
Compared to previous month
Last year
67.3%
39,903
Compared to previous year
24
simple libraray for jest-tested projects to create jest mock for js aws-sdk .promise() calls
i was tired to copy-paste my mock helpers across repos
1npm i -D @jurijzahn8019/aws-promise-jest-mock
in your code file
1export function foo() { 2 return new SecretsManager().getSecretValue({ SecretId: "bar-baz" }).promise(); 3}
in your spec file
1import { SecretsManager } from "aws-sdk"; 2import { on } from "@jurijzahn8019/aws-promise-jest-mock"; 3import { foo } from "./code.ts"; 4 5jest.mock("aws-sdk"); 6 7describe("aws-mock", () => { 8 it("Should succeed", async () => { 9 const m = on(SecretsManager) 10 .mock("getSecretValue") 11 .resolve({ SecretString: "foo-bar" }); 12 13 const res = foo(); 14 15 await expect(res).resolves.toMatchSnapshot("Result"); 16 expect(m.mock).toHaveBeenCalledTimes(1); 17 }); 18 19 it("Should fail", async () => { 20 const m = on(SecretsManager).mock("getSecretValue").reject("foo-baz"); 21 22 const res = foo(); 23 24 await expect(res).rejects.toMatchSnapshot("Result"); 25 expect(m.mock).toHaveBeenCalledTimes(1); 26 }); 27});
chain mocks
1import { SecretsManager } from "aws-sdk"; 2import { on } from "@jurijzahn8019/aws-promise-jest-mock"; 3import { foo } from "./code.ts"; 4 5jest.mock("aws-sdk"); 6 7describe("aws-mock", () => { 8 it("Should succeed", async () => { 9 const m = on(SecretsManager) 10 .mock("getSecretValue") 11 .resolveOnce({ SecretString: "foo-bar" }) 12 .resolveOnce({ SecretString: "baz-bar" }) 13 .rejectOnce({ SecretString: "baz-bar" }); 14 15 const res = foo(); 16 17 await expect(res).resolves.toMatchSnapshot("Result 1"); 18 await expect(res).resolves.toMatchSnapshot("Result 2"); 19 await expect(res).rejects.toMatchSnapshot("Error"); 20 21 expect(m.mock).toHaveBeenCalledTimes(3); 22 }); 23});
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
SAST tool detected but not run on all commits
Details
Reason
5 existing vulnerabilities detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More