Gathering detailed insights and metrics for @carlosrpj/jest-mock-express
Gathering detailed insights and metrics for @carlosrpj/jest-mock-express
Gathering detailed insights and metrics for @carlosrpj/jest-mock-express
Gathering detailed insights and metrics for @carlosrpj/jest-mock-express
npm install @carlosrpj/jest-mock-express
Typescript
Module System
Node Version
NPM Version
37.3
Supply Chain
52.9
Quality
65.4
Maintenance
50
Vulnerability
94.6
License
TypeScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
12 Commits
1 Watchers
1 Branches
1 Contributors
Updated on May 10, 2021
Latest Version
1.0.5
Package Id
@carlosrpj/jest-mock-express@1.0.5
Unpacked Size
16.96 kB
Size
4.59 kB
File Count
19
NPM Version
6.14.12
Node Version
14.16.1
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
3
This library simulates a http request to load express modules without start the application, working with Jest.
This mock receives the express router exported module. The MockRouter object has all http methods (get, post, put, delete), you can execute requests without start the entire application.
1import { MockRouter } from "@carlosrpj/jest-mock-express"; 2import router from "../../src/routes/api"; 3 4const mockRouter = new MockRouter(router); 5 6it("should return a user list", async () => { 7 await mockRouter.get("/users"); 8 expect(mockRouter.res.send).toBeCalledWith([ 9 { name: "Foo", email: "test@example.com" }, 10 ]); 11});
You can define your request headers with headers function, simulating a http request. This function replace all actual headers.
1await mockRouter 2 .headers({ 3 Authorization: "Bearer TOKEN", 4 "Content-Type": "application/json", 5 }) 6 .get("/users");
Adding a header to request.
1await mockRouter.header("Authorization", "Bearer TOKEN").get("/users");
Adding many params. This function replace all actual params.
1await mockRouter.params({ id: 1 }).get("/users/1");
Adding a param to request.
1await mockRouter.param("id", 1).get("/users/1");
Adding a query to request.
You can use a object with many queries, or a single key/value.
1// many queries 2await mockRouter.query({ id: 1 }).get("/users/1"); 3// single key/value 4await mockRouter.query("name", "foo").get("/users/1");
Adding a body to request.
1await mockRouter 2 .body({ name: "Foo", email: "test@example.com" }) 3 .post("/users");
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no SAST tool detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/12 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
22 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
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