Merge pull request #26905 from paambaati/master

@types/nock Introduce URL as input for nock
This commit is contained in:
Paul van Brenk
2018-06-29 10:26:18 -07:00
committed by GitHub
2 changed files with 11 additions and 2 deletions
+5 -2
View File
@@ -1,17 +1,20 @@
// Type definitions for nock v9.1.3
// Type definitions for nock v9.3.3
// Project: https://github.com/node-nock/nock
// Definitions by: bonnici <https://github.com/bonnici>
// Horiuchi_H <https://github.com/horiuchi>
// afharo <https://github.com/afharo>
// Matt R. Wilson <https://github.com/mastermatt>
// Garanzha Dmitriy <https://github.com/damour>
// GP <https://github.com/paambaati>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
import { Url } from 'url';
export = nock;
declare function nock(basePath: string | RegExp, options?: nock.Options): nock.Scope;
declare function nock(basePath: string | RegExp | Url, options?: nock.Options): nock.Scope;
declare namespace nock {
export function cleanAll(): void;
+6
View File
@@ -1,5 +1,6 @@
import nock = require('nock');
import * as fs from 'fs';
import { URL } from 'url';
var scope: nock.Scope;
var inst: nock.Interceptor;
@@ -144,6 +145,11 @@ var couchdb = nock('http://myapp.iriscouch.com')
email: 'pedro.teixeira@gmail.com'
});
// Using URL as input
var scope = nock(new URL('https://example.org/'))
.get('/resource')
.reply(200, 'url matched');
// Specifying hostname
var scope = nock('http://www.example.com')
.get('/resource')