Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@bonniernews/httptest

Package Overview
Dependencies
Maintainers
15
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bonniernews/httptest - npm Package Compare versions

Comparing version 1.1.0 to 2.0.0

4

CHANGELOG.md

@@ -11,2 +11,6 @@ Changelog

## [2.0.0] - 2022-08-23
### Changed
- Parse and return response body as JSON if content type matches application/json
## [1.1.0] - 2022-04-13

@@ -13,0 +17,0 @@ ### Added

@@ -8,2 +8,4 @@ "use strict";

const jsonContentTypePattern = /application\/json/i;
module.exports = HttpTest;

@@ -77,3 +79,3 @@

if (value) this._options.responseType = "json";
else delete this._options.responseType;
else this._options.responseType = "text";
return this;

@@ -124,2 +126,5 @@ }

const res = await makeRequest();
if (!("responseType" in this._options) && jsonContentTypePattern.test(res.headers["content-type"])) {
res.body = JSON.parse(res.text);
}
for (const test of this._asserts.splice(0)) {

@@ -126,0 +131,0 @@ test.fn.call(this, res, ...test.args);

20

package.json
{
"name": "@bonniernews/httptest",
"version": "1.1.0",
"description": "",
"version": "2.0.0",
"description": "HTTP testing library",
"main": "index.js",

@@ -30,13 +30,13 @@ "scripts": {

"cookiejar": "^2.1.3",
"got": "^11.8.3"
"got": "^11.8.5"
},
"devDependencies": {
"body-parser": "^1.19.2",
"c8": "^7.11.0",
"body-parser": "^1.20.0",
"c8": "^7.12.0",
"chai": "^4.3.6",
"eslint": "^8.10.0",
"eslint-config-exp": "^0.2.0",
"express": "^4.17.3",
"mocha": "^9.2.1",
"nock": "^13.2.4"
"eslint": "^8.22.0",
"eslint-config-exp": "^0.4.0",
"express": "^4.18.1",
"mocha": "^10.0.0",
"nock": "^13.2.9"
},

@@ -43,0 +43,0 @@ "files": [

@@ -80,2 +80,10 @@ HTTP Test

});
it("response content-type json returns body as JSON", async () => {
await HttpTest(app)
.post("/", {})
.expect(200)
.expect("content-type", "application/json; charset=utf-8")
.expect({ foo: "bar" });
});
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc