
Security News
Feross on the 10 Minutes or Less Podcast: Nobody Reads the Code
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.
json-api-tester
Advanced tools
This program takes a list of JSON api calls and checks you get back what you expected. It can be run on all files in a directory on a single file or simply pass in an object containing one or more tests. Internally it uses https://github.com/5app/json-assert to do the matching.
It can handle posting files, waiting a set time for the back-end to finish processing, and expecting set content-types or status codes.
npm install --save json-api-tester
The magic all-in-one program:
var jsonApiTester = require('json-api-tester');
var args = jsonApiTester.processCmdLineArgs(process.argv);
jsonApiTester.test(args);
A more telling example:
var jsonApiTester = require('json-api-tester');
var ja = require('json-assert');
var serverName = "https://api.5app.com";
var verbosity = 1;
var testArray = [
// check that doing a GET to `/hello` returns some JSON with a message
// of "hello world" and a 200 status code.
{
url: "/hello",
method: "GET",
status: 200,
returns: {
message: "hello world"
}
},
// wait 5 seconds for no real reason
{
wait: 5000
},
// do a post with JSON arguments
// we don't care what we get back
{
url: "/users/123",
method: "POST",
args: {
name: "bob",
size: "15",
hair: "none",
height: "162"
},
status: ja.matchType('number'),
returns: ja.dontCare()
}
];
jsonApiTester.testArray(arr, serverName, verbosity, function(err, result) {
});
npm test # unittests (mocha) and integration tests (literate DOCS.js)
npm run lint # styleguide and code smells
npm run fix # try to autofix styleguide errors
npm run cover # create a code coverage report
npm run docs # create HTML documentation
Make sure your code:
npm run lintnpm testThen submit a pull request.
FAQs
test json ajax calls using a simple json file
The npm package json-api-tester receives a total of 3 weekly downloads. As such, json-api-tester popularity was classified as not popular.
We found that json-api-tester demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.

Research
/Security News
Campaign of 108 extensions harvests identities, steals sessions, and adds backdoors to browsers, all tied to the same C2 infrastructure.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.