UNPKG

http-request-mock

Version:

Intercept & mock http requests issued by XMLHttpRequest, fetch, nodejs https/http module, axios, jquery, superagent, ky, node-fetch, request, got or any other request libraries by intercepting XMLHttpRequest, fetch and nodejs native requests in low level.

32 lines (31 loc) 938 B
import Bypass from '../common/bypass'; import { Headers, HttpVerb, MockItemInfo, RequestInfo } from '../types'; import { RemoteResponse } from './../types'; export default class MockItem { url: RegExp | string; regexp: Array<string>; method: HttpVerb; remoteRequestHeaders: Headers; header: Headers; headers: Headers; delay: number; body: unknown; response: unknown; remote: string; status: number; disable: 'YES' | 'NO'; times: number; key: string; deProxy: boolean; doOriginalRequest: Function; /** * Format specified mock item. * @param {MockItemInfo} mockItem * @returns false | MockItemInfo */ constructor(mockItem: MockItemInfo); private setBody; bypass(): Bypass; sendBody(requestInfo: RequestInfo, remoteResponse?: RemoteResponse | null): Promise<any>; getRemoteInfo(requestUrl: string): false | Record<string, string>; }