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

supertest-fetch

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

supertest-fetch - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

21

lib/index.js

@@ -14,2 +14,14 @@ "use strict";

exports.Response = node_fetch_1.Response;
/**
* Fetch a resource from a server, returns a Test.
*
* @param server - The server to fetch from. If the server is not already
* listening, this function will start it listening and then will close the
* server at the end of the test.
* @param url - A Request or a string representing a relative URL. Same as
* WHATWG Fetch. URL should be relative to the server (e.g. '/foo/bar').
* @param options - Same as WHATWG Fetch.
* @returns - a Test, which is like a Promise<Response>, but it also
* has 'exepect' methods on it.
*/
function fetch(server, url, init) {

@@ -27,2 +39,11 @@ if (!server || !server.listen || !server.address || !server.close) {

exports.fetch = fetch;
/**
* Creates a `fetch` function for a server.
*
* @param server - The server to fetch from. If the server is not already
* listening, th server will be started before each call to `fetch()`, and
* closed after each call.
* @returns - a `fetch(url, options)` function, compatible with WHATWG
* fetch, but which returns `Test` objects.
*/
function makeFetch(server) {

@@ -29,0 +50,0 @@ if (!server || !server.listen || !server.address || !server.close) {

45

package.json
{
"name": "supertest-fetch",
"version": "1.0.1",
"description": "Supertest with WHAT-WG fetch like interface.",
"version": "1.0.2",
"description": "Supertest with WHATWG fetch like interface.",
"main": "lib/index.js",

@@ -12,22 +12,25 @@ "types": "types/index.d.ts",

"scripts": {
"test": "npm run build && npm run test:lint && npm run test:unittest",
"test": "npm run build && npm run lint && npm run test:unittest",
"precommit:test": "npm run build && lint-staged && npm run precommit:unittest",
"build": "tsc",
"clean": "rm -rf lib types coverage",
"clean": "rm -rf dist coverage",
"test:unittest": "tsc -p test && nyc mocha 'test/**/*.@(ts|js)'",
"test:lint": "npm run test:lint:source && npm run test:lint:markdown && npm run test:lint:tests",
"test:lint:source": "tslint -c tslint.json -t stylish 'src/**/*.ts'",
"test:lint:tests": "tslint -c test/tslint.json -t stylish 'test/**/*.ts'",
"test:lint:markdown": "markdownlint README.md",
"test:pre-commit": "mocha --reporter progress 'test/**/*.@(ts|js)'",
"precommit:unittest": "tsc -p test && mocha --reporter progress 'test/**/*.@(ts|js)'",
"lint": "npm run lint:source && npm run lint:markdown && npm run lint:tests",
"lint:source": "tslint -c tslint.json -t stylish 'src/**/*.ts'",
"lint:tests": "tslint -c test/tslint.json -t stylish 'test/**/*.ts'",
"lint:markdown": "markdownlint src/**/*.md *.md",
"prepare": "npm run build",
"prepublishOnly": "npm run build && npm test"
"prepublishOnly": "npm run build && npm test",
"semantic-release": "semantic-release"
},
"pre-commit": [
"build",
"test:lint",
"test:pre-commit"
],
"husky": {
"hooks": {
"commit-msg": "validate-commit-msg",
"pre-commit": "npm run precommit:test"
}
},
"repository": {
"type": "git",
"url": "git+https://github.com/jwalton/supertest-fetch.git"
"url": "git+https://github.com/jwalton/node-supertest-fetch.git"
},

@@ -43,5 +46,5 @@ "keywords": [

"bugs": {
"url": "https://github.com/jwalton/supertest-fetch/issues"
"url": "https://github.com/jwalton/node-supertest-fetch/issues"
},
"homepage": "https://github.com/jwalton/supertest-fetch#readme",
"homepage": "https://github.com/jwalton/node-supertest-fetch#readme",
"devDependencies": {

@@ -55,2 +58,3 @@ "@types/chai": "^4.1.3",

"coveralls": "^3.0.0",
"lint-staged": "^7.0.5",
"markdownlint": "^0.8.1",

@@ -60,6 +64,7 @@ "markdownlint-cli": "^0.8.1",

"nyc": "^11.7.1",
"pre-commit": "^1.2.2",
"semantic-release": "^15.2.0",
"ts-node": "^6.0.1",
"tslint": "^5.9.1",
"typescript": "^2.8.3"
"typescript": "^2.8.3",
"validate-commit-msg": "^2.14.0"
},

@@ -66,0 +71,0 @@ "dependencies": {

@@ -14,3 +14,3 @@ # supertest-fetch

* Uses [node-fetch](https://github.com/bitinn/node-fetch) to give you a
[WHAT-WG Fetch](https://github.github.io/fetch)-like interface.
[WHATWG Fetch](https://github.github.io/fetch)-like interface.
* Should be instantly familiar to anyone who has used supertest.

@@ -32,3 +32,3 @@ * First class support for promises.

// This is a function with an API identical to the WHAT-WG `fetch()` function,
// This is a function with an API identical to the WHATWG `fetch()` function,
// except the returned Promise has a bunch of supertest like functions on it.

@@ -35,0 +35,0 @@ //

@@ -7,4 +7,25 @@ /// <reference types="node" />

export { Body, Request, RequestInit, RequestContext, RequestMode, RequestRedirect, RequestCredentials, RequestCache, Headers, Response, ResponseType, ResponseInit, HeaderInit, BodyInit, RequestInfo } from 'node-fetch';
/**
* Fetch a resource from a server, returns a Test.
*
* @param server - The server to fetch from. If the server is not already
* listening, this function will start it listening and then will close the
* server at the end of the test.
* @param url - A Request or a string representing a relative URL. Same as
* WHATWG Fetch. URL should be relative to the server (e.g. '/foo/bar').
* @param options - Same as WHATWG Fetch.
* @returns - a Test, which is like a Promise<Response>, but it also
* has 'exepect' methods on it.
*/
export default function fetch(server: http.Server, url: string | nodeFetch.Request, init?: nodeFetch.RequestInit): Test;
/**
* Creates a `fetch` function for a server.
*
* @param server - The server to fetch from. If the server is not already
* listening, th server will be started before each call to `fetch()`, and
* closed after each call.
* @returns - a `fetch(url, options)` function, compatible with WHATWG
* fetch, but which returns `Test` objects.
*/
export declare function makeFetch(server: http.Server): (url: string | nodeFetch.Request, init?: nodeFetch.RequestInit | undefined) => Test;
export { fetch };

Sorry, the diff of this file is not supported yet

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