Gathering detailed insights and metrics for assert-responselike
Gathering detailed insights and metrics for assert-responselike
Gathering detailed insights and metrics for assert-responselike
Gathering detailed insights and metrics for assert-responselike
An ultra simple all-test-framework friendly utility, meant to be used with the test framework of your choice, decorates the built-in assert object with a new method responseLike(res,exp,msg)
npm install assert-responselike
Typescript
Module System
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
1 Stars
12 Commits
2 Watchers
1 Branches
1 Contributors
Updated on Jan 27, 2016
Latest Version
0.6.4
Package Id
assert-responselike@0.6.4
Size
3.20 kB
NPM Version
1.4.28
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
This is an ultra simple all-test-framework friendly utility, meant to be used with the test framework of your choice, decorates the built-in assert object with a new method responseLike(res,exp,msg)
usage :
var assert = require("assert");
, request = require('your favorite http request lib')
, test = require('your favorite test function of your favorite framework')
;
require("assert-responselike");
test( "foo", function() {
request(url, function(response){
assert.responseLike( response
, { status : 200 //throws 'Invalid response code - expected ... got ...'
, statusCode : 200 //same like status, for the explicitness lovers..
, headers :
{ "Content-Type" : "text/plain" //throws 'response-header - expected ... got ...'
}
, body : "run vows for full spec" //throws 'Invalid response body - expected ... got ...'
}
);
});
});
using NPM
npm install assert-responselike
esample of output:
D:\work\mymodule>npm install assert-responselike
npm http GET https://registry.npmjs.org/assert-responselike
npm http 304 https://registry.npmjs.org/assert-responselike
assert-responselike@0.2.0 ./node_modules/assert-responselike
Do it yourself
download the zip from github, and extract it to your ./node_modules/ directory.
example of structure Either way - expect the following:
└───node_modules
└───assert-responselike
│ .npmignore
│ index.js
│ package.json
│ README.md
│
└───test
assert-response-test.js
after extracting first you have to :
npm install
esample of output:
D:\work\assert-responseLike>npm install
npm http GET https://registry.npmjs.org/vows
npm http 304 https://registry.npmjs.org/vows
npm http GET https://registry.npmjs.org/eyes
npm http 304 https://registry.npmjs.org/eyes
npm WARN eyes@0.1.7 dependencies field should be hash of <name>:<version-range> pairs
vows@0.6.3 ./node_modules/vows
└── eyes@0.1.7
and then vows --spec
node ./node_modules/vows/bin/vows --spec
? assert response
API
√ assert should be decorated with the method:
assert.responseLike ( oActualResponse, oExpectedDescr, sCustomMessage )
check status code with attribute 'status'
√ providing correct numner should work
√ providing wrong number should throw
check status code with attribute 'statusCode'
√ providing correct number should work
√ providing wrong number should throw
check response headers
√ providing existing headers should work - case insensitive
√ providing wrong headers throw on the first mismatch
√ providing missing headers throw on the first misfound
check response body
√ regexp body descriptor that matches should not throw
√ regexp body descriptor that does not match should throw
√ when descriptor is not a RegExp, and body is object - deep equal match should not throw
√ when descriptor is not a RegExp, and body is object - deep equal difference should throw
check response headers - provide expected content
√ equal string - should pass
√ different string - should throw
√ matching regexp - should pass
√ non-matching regexp - should throw
thrown errors - when providing a message
√ should trail status-code error messages
√ should trail response-header error messages
√ should trail response-body error messages
thrown errors - a status-code check error message
√ should start with 'Invalid response status code'
√ should contain the expected response code
√ should contain the actual response code
thrown errors - a missing response-header check error message
√ should start with 'response header'
√ should contain the expected response header name
√ should contain the expected response header value
√ should contain the actual response value
thrown errors - a mismatching response-header check error message
√ should start with 'response header'
√ should contain the expected response header name
√ should contain the expected response header value
√ should contain the actual response value
√ OK » 30 honored (0.183s)
It's not the most genious utility or anything, it is meant to be my first git hub project. I use it to test responses of web-requests to web projects, with vows.
The basis of the implementation is taken from from expresso, that did not work well for me on windows, and the implementation there is coupled with the request firing itself - and I did not like that. so now I can use the same assert description language with any test-framework i like, and use whatever request tools I want.
I don't know what i need to do to make it officual under whatever lisence is up there... I took from 'the community' so I give back. Take it, as is, I give no warantee. Do with it whatever you want on your own responsibility.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
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 SAST tool detected
Details
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
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