Gathering detailed insights and metrics for protractor-api-resource
Gathering detailed insights and metrics for protractor-api-resource
npm install protractor-api-resource
Typescript
Module System
Node Version
NPM Version
37.5
Supply Chain
85.4
Quality
65.8
Maintenance
25
Vulnerability
93.9
License
TypeScript (68.3%)
JavaScript (31.7%)
Total Downloads
69,841
Last Day
14
Last Week
48
Last Month
260
Last Year
10,915
4 Stars
12 Commits
3 Forks
3 Watching
1 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
1.0.3
Package Id
protractor-api-resource@1.0.3
Unpacked Size
14.53 kB
Size
4.54 kB
File Count
8
NPM Version
5.6.0
Node Version
8.11.1
Cumulative downloads
Total Downloads
Last day
100%
14
Compared to previous day
Last week
-20%
48
Compared to previous week
Last month
-17.7%
260
Compared to previous month
Last year
-46.5%
10,915
Compared to previous year
API testing is now made simple with protractor. protractor-api-resource is a REST Client framework created using request npm module to use in protractor tests for making API calls. Register all service endpoints as individual service methods and reuse the same inside the test. Inspired from angular-resource project.
If you are using Protractor for e2e testing and you need to get test data from API then this module will come handy with lot of predefined functionalities.
$ npm install protractor-api-resource
Using javascript, first import the npm module in your tests.
1const apiResource = require("protractor-api-resource").ProtractorApiResource
1describe("Test response for all REST API methods", function () { 2 3 var apiClient, serviceEnpoints = { 4 getPosts: { 5 path: "/posts/:postId:" 6 }, 7 createPost: { 8 path: "/posts", 9 method: "POST" 10 }, 11 updatePost: { 12 path: "/posts/:postId:", 13 method: "PUT" 14 }, 15 patchPost: { 16 path: "/posts/:postId:", 17 method: "PATCH" 18 }, 19 }; 20 21 beforeAll(function () { 22 apiClient = new apiResource("https://jsonplaceholder.typicode.com/"); 23 apiClient.registerService(serviceEnpoints); 24 }); 25});
Thats it. Now you can directly access the service endpoints from your tests as below.
1it("Test GET method", function (done) { 2 var expectedResponse = { 3 "userId": 1, 4 "id": 1, 5 "title": "sunt aut facere repellat provident occaecati excepturi optio reprehenderit", 6 "body": "quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto" 7 }; 8 9 apiClient.getPosts({postId: 1}).toJSON().then(function (actualResponse) { 10 expect(actualResponse).toEqual(expectedResponse); 11 done(); 12 }); 13}); 14
For POST,PUT and PATCH calls, you can also send payloads like,
1it("Test POST method", function (done) { 2 var payLoad = { 3 title: 'foo', 4 body: 'bar', 5 userId: 1 6 }; 7 8 var expectedResponse = { 9 id: 101, 10 title: 'foo', 11 body: 'bar', 12 userId: 1 13 }; 14 //First parameter is for query params and second parameter is for request payload. 15 apiClient.createPost({}, payLoad).toJSON().then(function (actualResponse) { 16 expect(actualResponse).toEqual(expectedResponse); 17 done(); 18 }); 19});
toJson()
method will parse the API respose and returns the respective JSON object and toSting()
willl return the plain string.
It's very simple. Just mention the type of authentication at the time of creating a object.
1var apiClient = new apiResource("https://jsonplaceholder.typicode.com/").withBasicAuth(username,password);
1var apiClient = new apiResource("https://jsonplaceholder.typicode.com/").withTokenAuthentication(token);
You can also modify the authencation type any time inside the tests using apiClient .withTokenAuthentication(token)
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
Found 0/12 approved changesets -- score normalized to 0
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
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-01-27
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