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

@jest-mock/express

Package Overview
Dependencies
Maintainers
2
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jest-mock/express - npm Package Compare versions

Comparing version 1.4.5 to 2.0.0-beta-1

dist/src/index.d.ts

2

.prettierrc.js

@@ -11,3 +11,3 @@ module.exports = {

bracketSpacing: true,
jsxBracketSameLine: true
bracketSameLine: true,
}

@@ -1,58 +0,88 @@

import { MediaType } from 'express-serve-static-core';
interface MockIncomingMessage {
aborted?: boolean;
httpVersion?: string;
httpVersionMajor?: number;
httpVersionMinor?: number;
complete?: boolean;
connection?: any;
socket?: any;
headers?: any;
rawHeaders?: string[];
trailers?: {
[key: string]: string | undefined;
};
rawTrailers?: string[];
setTimeout?: any;
statusCode?: number;
statusMessage?: string;
destroy?: any;
/// <reference types="jest" />
/// <reference types="node" />
/// <reference types="node" />
import type { IncomingMessage } from 'http';
import type { Readable } from 'stream';
import type { Request } from 'express-serve-static-core';
import type { EventEventEmitter } from 'src';
interface StreamReadable extends EventEventEmitter {
readable?: Readable['readable'];
readableHighWaterMark?: Readable['readableHighWaterMark'];
readableLength?: Readable['readableLength'];
readableObjectMode?: Readable['readableObjectMode'];
destroyed?: Readable['destroyed'];
_read?: jest.Mock;
read?: jest.Mock;
setEncoding?: jest.Mock;
pause?: jest.Mock;
resume?: jest.Mock;
isPaused?: jest.Mock;
unpipe?: jest.Mock;
unshift?: jest.Mock;
wrap?: jest.Mock;
push?: jest.Mock;
_destroy?: jest.Mock;
addListener?: jest.Mock;
emit?: jest.Mock;
on?: jest.Mock;
once?: jest.Mock;
prependListener?: jest.Mock;
prependOnceListener?: jest.Mock;
removeListener?: jest.Mock;
destroy?: jest.Mock;
}
export interface MockRequest extends MockIncomingMessage {
params?: any;
query?: any;
body?: any;
cookies?: any;
method?: string;
protocol?: string;
secure?: boolean;
ip?: string;
ips?: string[];
subdomains?: string[];
path?: string;
hostname?: string;
host?: string;
fresh?: boolean;
stale?: boolean;
xhr?: boolean;
route?: any;
signedCookies?: any;
originalUrl?: string;
url?: string;
baseUrl?: string;
accepted?: MediaType[];
get?: any;
header?: any;
accepts?: any;
acceptsCharsets?: any;
acceptsEncodings?: any;
acceptsLanguages?: any;
range?: any;
param?: any;
is?: any;
app?: any;
res?: any;
next?: any;
interface HttpIncomingMessage extends StreamReadable {
aborted?: IncomingMessage['aborted'];
httpVersion?: IncomingMessage['httpVersion'];
httpVersionMajor?: IncomingMessage['httpVersionMajor'];
httpVersionMinor?: IncomingMessage['httpVersionMinor'];
complete?: IncomingMessage['complete'];
connection?: Partial<IncomingMessage['connection']>;
socket?: Partial<IncomingMessage['socket']>;
headers?: Partial<IncomingMessage['headers']>;
rawHeaders?: IncomingMessage['rawHeaders'];
trailers?: IncomingMessage['trailers'];
rawTrailers?: IncomingMessage['rawTrailers'];
setTimeout?: jest.Mock;
statusCode?: IncomingMessage['statusCode'];
statusMessage?: IncomingMessage['statusMessage'];
destroy?: jest.Mock;
}
export interface MockRequest extends HttpIncomingMessage {
params?: Request['params'];
query?: Request['query'];
body?: Request['body'];
cookies?: Request['cookies'];
method?: Request['method'];
protocol?: Request['protocol'];
secure?: Request['secure'];
ip?: Request['ip'];
ips?: Request['ips'];
subdomains?: Request['subdomains'];
path?: Request['path'];
hostname?: Request['hostname'];
host?: Request['host'];
fresh?: Request['fresh'];
stale?: Request['stale'];
xhr?: Request['xhr'];
route?: Request['route'];
signedCookies?: Request['signedCookies'];
originalUrl?: Request['originalUrl'];
url?: Request['url'];
baseUrl?: Request['baseUrl'];
accepted?: Request['accepted'];
get?: jest.Mock;
header?: jest.Mock;
accepts?: jest.Mock;
acceptsCharsets?: jest.Mock;
acceptsEncodings?: jest.Mock;
acceptsLanguages?: jest.Mock;
range?: jest.Mock;
param?: jest.Mock;
is?: jest.Mock;
app?: Partial<Request['app']>;
res?: Partial<Request['res']>;
next?: jest.Mock;
[key: string]: any;
}
export {};

@@ -6,3 +6,3 @@ import { Request } from 'express';

*/
export declare const getMockReq: <T extends Request<import("express-serve-static-core").ParamsDictionary, any, any, any, Record<string, any>>>(values?: MockRequest) => T;
export declare const getMockReq: <T extends Request<import("express-serve-static-core").ParamsDictionary, any, any, ParsedQs, Record<string, any>>>(values?: MockRequest) => T;
export default getMockReq;

@@ -19,4 +19,26 @@ "use strict";

const getMockReq = (values = {}) => {
const { params = {}, query = {}, body = {}, cookies = {}, method = '', protocol = '', secure = false, ip = '', ips = [], subdomains = [], path = '', hostname = '', host = '', fresh = false, stale = false, xhr = false, route = {}, signedCookies = {}, originalUrl = '', url = '', baseUrl = '', accepted = [], get = jest.fn().mockName('get mock default'), header = jest.fn().mockName('header mock default'), accepts = jest.fn().mockName('accepts mock default'), acceptsCharsets = jest.fn().mockName('acceptsCharsets mock default'), acceptsEncodings = jest.fn().mockName('acceptsEncodings mock default'), acceptsLanguages = jest.fn().mockName('acceptsLanguages mock default'), range = jest.fn().mockName('range mock default'), param = jest.fn().mockName('param mock default'), is = jest.fn().mockName('is mock default'), app = {}, res = jest.fn().mockName('res mock default'), next = jest.fn().mockName('next mock default'), aborted = false, httpVersion = '', httpVersionMajor = 0, httpVersionMinor = 0, complete = false, connection = {}, socket = {}, headers = {}, rawHeaders = [], trailers = {}, rawTrailers = [], setTimeout = jest.fn().mockName('setTimeout mock default'), statusCode = 0, statusMessage = '', destroy = jest.fn().mockName('destroy mock default') } = values, extraProvidedValues = __rest(values, ["params", "query", "body", "cookies", "method", "protocol", "secure", "ip", "ips", "subdomains", "path", "hostname", "host", "fresh", "stale", "xhr", "route", "signedCookies", "originalUrl", "url", "baseUrl", "accepted", "get", "header", "accepts", "acceptsCharsets", "acceptsEncodings", "acceptsLanguages", "range", "param", "is", "app", "res", "next", "aborted", "httpVersion", "httpVersionMajor", "httpVersionMinor", "complete", "connection", "socket", "headers", "rawHeaders", "trailers", "rawTrailers", "setTimeout", "statusCode", "statusMessage", "destroy"]);
return Object.assign({ params,
const {
/* express.Request */
params = {}, query = {}, body = {}, cookies = {}, method = '', protocol = '', secure = false, ip = '', ips = [], subdomains = [], path = '', hostname = '', host = '', fresh = false, stale = false, xhr = false, route = {}, signedCookies = {}, originalUrl = '', url = '', baseUrl = '', accepted = [], get = jest.fn().mockName('get mock default'), header = jest.fn().mockName('header mock default'), accepts = jest.fn().mockName('accepts mock default'), acceptsCharsets = jest.fn().mockName('acceptsCharsets mock default'), acceptsEncodings = jest.fn().mockName('acceptsEncodings mock default'), acceptsLanguages = jest.fn().mockName('acceptsLanguages mock default'), range = jest.fn().mockName('range mock default'), param = jest.fn().mockName('param mock default'), is = jest.fn().mockName('is mock default'), app = {}, res = jest.fn().mockName('res mock default'), next = jest.fn().mockName('next mock default'),
/* http.IncomingMessage */
aborted = false, httpVersion = '', httpVersionMajor = 0, httpVersionMinor = 0, complete = false, connection = {}, socket = {}, headers = {}, rawHeaders = [], trailers = {}, rawTrailers = [], setTimeout = jest.fn().mockName('setTimeout mock default'), statusCode = 0, statusMessage = '', destroy = jest.fn().mockName('destroy mock default'),
/* stream.Readable */
readable = false, readableHighWaterMark = 0, readableLength = 0, readableObjectMode = false, destroyed = false, _read = jest.fn().mockName('_read mock default'), read = jest.fn().mockName('read mock default'), setEncoding = jest.fn().mockName('setEncoding mock default'), pause = jest.fn().mockName('pause mock default'), resume = jest.fn().mockName('resume mock default'), isPaused = jest.fn().mockName('isPaused mock default'), unpipe = jest.fn().mockName('unpipe mock default'), unshift = jest.fn().mockName('unshift mock default'), wrap = jest.fn().mockName('wrap mock default'), push = jest.fn().mockName('push mock default'), _destroy = jest.fn().mockName('_destroy mock default'), addListener = jest.fn().mockName('addListener mock default'), emit = jest.fn().mockName('emit mock default'), on = jest.fn().mockName('on mock default'), once = jest.fn().mockName('once mock default'), prependListener = jest.fn().mockName('prependListener mock default'), prependOnceListener = jest.fn().mockName('prependOnceListener mock default'), removeListener = jest.fn().mockName('removeListener mock default'),
// destroy - is handled/overridden as part of http.IncomingMessage
/* event.EventEmitter */
// addListener - is handled/overridden as part of stream.Readable
// on - is handled/overridden as part of stream.Readable
// once - is handled/overridden as part of stream.Readable
// removeListener - is handled/overridden as part of stream.Readable
off = jest.fn().mockName('off mock default'), removeAllListeners = jest.fn().mockName('removeAllListeners mock default'), setMaxListeners = jest.fn().mockName('setMaxListeners mock default'), getMaxListeners = jest.fn().mockName('getMaxListeners mock default'), listeners = jest.fn().mockName('listeners mock default'), rawListeners = jest.fn().mockName('rawListeners mock default'),
// emit - is handled/overridden as part of stream.Readable
listenerCount = jest.fn().mockName('listenerCount mock default'),
// prependListener - is handled/overridden as part of stream.Readable
// prependOnceListener - is handled/overridden as part of stream.Readable
eventNames = jest.fn().mockName('eventNames mock default') } = values,
// custom values
extraProvidedValues = __rest(values, ["params", "query", "body", "cookies", "method", "protocol", "secure", "ip", "ips", "subdomains", "path", "hostname", "host", "fresh", "stale", "xhr", "route", "signedCookies", "originalUrl", "url", "baseUrl", "accepted", "get", "header", "accepts", "acceptsCharsets", "acceptsEncodings", "acceptsLanguages", "range", "param", "is", "app", "res", "next", "aborted", "httpVersion", "httpVersionMajor", "httpVersionMinor", "complete", "connection", "socket", "headers", "rawHeaders", "trailers", "rawTrailers", "setTimeout", "statusCode", "statusMessage", "destroy", "readable", "readableHighWaterMark", "readableLength", "readableObjectMode", "destroyed", "_read", "read", "setEncoding", "pause", "resume", "isPaused", "unpipe", "unshift", "wrap", "push", "_destroy", "addListener", "emit", "on", "once", "prependListener", "prependOnceListener", "removeListener", "off", "removeAllListeners", "setMaxListeners", "getMaxListeners", "listeners", "rawListeners", "listenerCount", "eventNames"]);
const request = Object.assign({
/* express.Request */
params,
query,

@@ -55,3 +77,3 @@ body,

next,
// http - IncomingMessage
/* http.IncomingMessage */
aborted,

@@ -71,3 +93,45 @@ httpVersion,

statusMessage,
destroy }, extraProvidedValues);
destroy,
/* stream.Readable */
readable,
readableHighWaterMark,
readableLength,
readableObjectMode,
destroyed,
_read,
read,
setEncoding,
pause,
resume,
isPaused,
unpipe,
unshift,
wrap,
push,
_destroy,
addListener,
emit,
on,
once,
prependListener,
prependOnceListener,
removeListener,
// destroy - is handled/overridden as part of http.IncomingMessage
/* event.EventEmitter */
// addListener - is handled/overridden as part of stream.Readable
// on - is handled/overridden as part of stream.Readable
// once - is handled/overridden as part of stream.Readable
// removeListener - is handled/overridden as part of stream.Readable
off,
removeAllListeners,
setMaxListeners,
getMaxListeners,
listeners,
rawListeners,
// emit - is handled/overridden as part of stream.Readable
listenerCount,
// prependListener - is handled/overridden as part of stream.Readable
// prependOnceListener - is handled/overridden as part of stream.Readable
eventNames }, extraProvidedValues);
return request;
};

@@ -74,0 +138,0 @@ exports.getMockReq = getMockReq;

@@ -1,18 +0,95 @@

export interface MockResponse {
headersSent?: boolean;
charset?: string;
req?: any;
app?: any;
locals?: any;
statusCode?: number;
statusMessage?: string;
upgrading?: boolean;
chunkedEncoding?: boolean;
shouldKeepAlive?: boolean;
useChunkedEncodingByDefault?: boolean;
sendDate?: boolean;
finished?: boolean;
connection?: any;
socket?: any;
/// <reference types="jest" />
/// <reference types="node" />
/// <reference types="node" />
import type { ServerResponse, OutgoingMessage, IncomingMessage } from 'http';
import type { Writable } from 'stream';
import type { Response } from 'express';
import type { EventEventEmitter } from 'src';
interface StreamWritable extends EventEventEmitter {
writable?: Writable['writable'];
writableEnded?: Writable['writableEnded'];
writableFinished?: Writable['writableFinished'];
writableHighWaterMark?: Writable['writableHighWaterMark'];
writableLength?: Writable['writableLength'];
writableObjectMode?: Writable['writableObjectMode'];
writableCorked?: Writable['writableCorked'];
destroyed?: Writable['destroyed'];
_write?: jest.Mock;
_writev?: jest.Mock;
_destroy?: jest.Mock;
_final?: jest.Mock;
write?: jest.Mock;
setDefaultEncoding?: jest.Mock;
end?: jest.Mock;
cork?: jest.Mock;
uncork?: jest.Mock;
destroy?: jest.Mock;
addListener?: jest.Mock;
emit?: jest.Mock;
on?: jest.Mock;
once?: jest.Mock;
prependListener?: jest.Mock;
prependOnceListener?: jest.Mock;
removeListener?: jest.Mock;
}
interface HttpOutgoingMessage extends StreamWritable {
req?: Partial<IncomingMessage>;
chunkedEncoding?: OutgoingMessage['chunkedEncoding'];
shouldKeepAlive?: OutgoingMessage['shouldKeepAlive'];
useChunkedEncodingByDefault?: OutgoingMessage['useChunkedEncodingByDefault'];
sendDate?: OutgoingMessage['sendDate'];
finished?: OutgoingMessage['finished'];
headersSent?: OutgoingMessage['headersSent'];
connection?: Partial<OutgoingMessage['connection']>;
socket?: Partial<OutgoingMessage['socket']>;
setTimeout?: jest.Mock;
setHeader?: jest.Mock;
getHeader?: jest.Mock;
getHeaders?: jest.Mock;
getHeaderNames?: jest.Mock;
hasHeader?: jest.Mock;
removeHeader?: jest.Mock;
addTrailers?: jest.Mock;
flushHeaders?: jest.Mock;
}
interface HttpServerResponse extends HttpOutgoingMessage {
statusCode?: ServerResponse['statusCode'];
statusMessage?: ServerResponse['statusMessage'];
assignSocket?: jest.Mock;
detachSocket?: jest.Mock;
writeContinue?: jest.Mock;
writeHead?: jest.Mock;
writeProcessing?: jest.Mock;
}
export interface MockResponse extends HttpServerResponse {
status?: jest.Mock;
sendStatus?: jest.Mock;
links?: jest.Mock;
send?: jest.Mock;
json?: jest.Mock;
jsonp?: jest.Mock;
sendFile?: jest.Mock;
sendfile?: jest.Mock;
download?: jest.Mock;
contentType?: jest.Mock;
type?: jest.Mock;
format?: jest.Mock;
attachment?: jest.Mock;
set?: jest.Mock;
header?: jest.Mock;
headersSent?: Response['headersSent'];
get?: jest.Mock;
clearCookie?: jest.Mock;
cookie?: jest.Mock;
location?: jest.Mock;
redirect?: jest.Mock;
render?: jest.Mock;
locals?: Partial<Response['locals']>;
charset?: Response['charset'];
vary?: jest.Mock;
app?: Partial<Response['app']>;
append?: jest.Mock;
req?: Partial<Response['req']>;
[key: string]: any;
}
export {};

@@ -24,15 +24,66 @@ "use strict";

const next = jest.fn();
const { headersSent = false, locals = {}, charset = '', app = {}, req = {}, statusCode = 0, statusMessage = '', upgrading = false, chunkedEncoding = false, shouldKeepAlive = false, useChunkedEncodingByDefault = false, sendDate = false, finished = false, connection = {}, socket = {} } = values, extraProvidedValues = __rest(values, ["headersSent", "locals", "charset", "app", "req", "statusCode", "statusMessage", "upgrading", "chunkedEncoding", "shouldKeepAlive", "useChunkedEncodingByDefault", "sendDate", "finished", "connection", "socket"]);
const {
/* express.Response */
status = jest.fn().mockName('status mock default'), sendStatus = jest.fn().mockName('sendStatus mock default'), links = jest.fn().mockName('links mock default'), send = jest.fn().mockName('send mock default'), json = jest.fn().mockName('json mock default'), jsonp = jest.fn().mockName('jsonp mock default'), sendFile = jest.fn().mockName('sendFile mock default'), sendfile = jest.fn().mockName('sendfile mock default'), download = jest.fn().mockName('download mock default'), contentType = jest.fn().mockName('contentType mock default'), type = jest.fn().mockName('type mock default'), format = jest.fn().mockName('format mock default'), attachment = jest.fn().mockName('attachment mock default'), set = jest.fn().mockName('set mock default'), header = jest.fn().mockName('header mock default'), headersSent = false, get = jest.fn().mockName('get mock default'), clearCookie = jest.fn().mockName('clearCookie mock default'), cookie = jest.fn().mockName('cookie mock default'), location = jest.fn().mockName('location mock default'), redirect = jest.fn().mockName('redirect mock default'), render = jest.fn().mockName('render mock default'), locals = {}, charset = '', vary = jest.fn().mockName('vary mock default'), app = {}, append = jest.fn().mockName('append mock default'), req = {},
/* http.ServerResponse */
statusCode = 0, statusMessage = '', assignSocket = jest.fn().mockName('assignSocket mock default'), detachSocket = jest.fn().mockName('detachSocket mock default'), writeContinue = jest.fn().mockName('writeContinue mock default'), writeHead = jest.fn().mockName('writeHead mock default'), writeProcessing = jest.fn().mockName('writeProcessing mock default'),
/* http.OutgoingMessage */
// req - is handled/overridden as part of express.Response
chunkedEncoding = false, shouldKeepAlive = false, useChunkedEncodingByDefault = false, sendDate = false, finished = false,
// headersSent - is handled/overridden as part of express.Response
connection = {}, socket = {}, setTimeout = jest.fn().mockName('setTimeout mock default'), setHeader = jest.fn().mockName('setHeader mock default'), getHeader = jest.fn().mockName('getHeader mock default'), getHeaders = jest.fn().mockName('getHeaders mock default'), getHeaderNames = jest.fn().mockName('getHeaderNames mock default'), hasHeader = jest.fn().mockName('hasHeader mock default'), removeHeader = jest.fn().mockName('removeHeader mock default'), addTrailers = jest.fn().mockName('addTrailers mock default'), flushHeaders = jest.fn().mockName('flushHeaders mock default'),
/* stream.Writable */
writable = false, writableEnded = false, writableFinished = false, writableHighWaterMark = 0, writableLength = 0, writableObjectMode = false, writableCorked = 0, destroyed = false, _write = jest.fn().mockName('_write mock default'), _writev = jest.fn().mockName('_writev mock default'), _destroy = jest.fn().mockName('_destroy mock default'), _final = jest.fn().mockName('_final mock default'), write = jest.fn().mockName('write mock default'), setDefaultEncoding = jest.fn().mockName('setDefaultEncoding mock default'), end = jest.fn().mockName('end mock default'), cork = jest.fn().mockName('cork mock default'), uncork = jest.fn().mockName('uncork mock default'), destroy = jest.fn().mockName('destroy mock default'), addListener = jest.fn().mockName('addListener mock default'), emit = jest.fn().mockName('emit mock default'), on = jest.fn().mockName('on mock default'), once = jest.fn().mockName('once mock default'), prependListener = jest.fn().mockName('prependListener mock default'), prependOnceListener = jest.fn().mockName('prependOnceListener mock default'), removeListener = jest.fn().mockName('removeListener mock default'),
/* event.EventEmitter */
// addListener - is handled/overridden as part of stream.Writable
// on - is handled/overridden as part of stream.Writable
// once - is handled/overridden as part of stream.Writable
// removeListener - is handled/overridden as part of stream.Writable
off = jest.fn().mockName('off mock default'), removeAllListeners = jest.fn().mockName('removeAllListeners mock default'), setMaxListeners = jest.fn().mockName('setMaxListeners mock default'), getMaxListeners = jest.fn().mockName('getMaxListeners mock default'), listeners = jest.fn().mockName('listeners mock default'), rawListeners = jest.fn().mockName('rawListeners mock default'),
// emit - is handled/overridden as part of stream.Writable
listenerCount = jest.fn().mockName('listenerCount mock default'),
// prependListener - is handled/overridden as part of stream.Writable
// prependOnceListener - is handled/overridden as part of stream.Writable
eventNames = jest.fn().mockName('eventNames mock default') } = values,
// custom values
extraProvidedValues = __rest(values, ["status", "sendStatus", "links", "send", "json", "jsonp", "sendFile", "sendfile", "download", "contentType", "type", "format", "attachment", "set", "header", "headersSent", "get", "clearCookie", "cookie", "location", "redirect", "render", "locals", "charset", "vary", "app", "append", "req", "statusCode", "statusMessage", "assignSocket", "detachSocket", "writeContinue", "writeHead", "writeProcessing", "chunkedEncoding", "shouldKeepAlive", "useChunkedEncodingByDefault", "sendDate", "finished", "connection", "socket", "setTimeout", "setHeader", "getHeader", "getHeaders", "getHeaderNames", "hasHeader", "removeHeader", "addTrailers", "flushHeaders", "writable", "writableEnded", "writableFinished", "writableHighWaterMark", "writableLength", "writableObjectMode", "writableCorked", "destroyed", "_write", "_writev", "_destroy", "_final", "write", "setDefaultEncoding", "end", "cork", "uncork", "destroy", "addListener", "emit", "on", "once", "prependListener", "prependOnceListener", "removeListener", "off", "removeAllListeners", "setMaxListeners", "getMaxListeners", "listeners", "rawListeners", "listenerCount", "eventNames"]);
const response = Object.assign({
// express - Response
status: jest.fn(), sendStatus: jest.fn(), links: jest.fn(), send: jest.fn(), json: jest.fn(), jsonp: jest.fn(), sendFile: jest.fn(), sendfile: jest.fn(), download: jest.fn(), contentType: jest.fn(), type: jest.fn(), format: jest.fn(), attachment: jest.fn(), set: jest.fn(), header: jest.fn(), get: jest.fn(), clearCookie: jest.fn(), cookie: jest.fn(), location: jest.fn(), redirect: jest.fn(), render: jest.fn(), vary: jest.fn(), append: jest.fn(), headersSent,
/* express.Response */
status,
sendStatus,
links,
send,
json,
jsonp,
sendFile,
sendfile,
download,
contentType,
type,
format,
attachment,
set,
header,
get,
clearCookie,
cookie,
location,
redirect,
render,
vary,
append,
headersSent,
locals,
charset,
app,
req,
// http - ServerResponse
end: jest.fn(), assignSocket: jest.fn(), detachSocket: jest.fn(), writeContinue: jest.fn(), writeHead: jest.fn(), writeProcessing: jest.fn(), statusCode,
statusMessage,
// http - OutgoingMessage
setTimeout: jest.fn(), setHeader: jest.fn(), getHeader: jest.fn(), getHeaders: jest.fn(), getHeaderNames: jest.fn(), hasHeader: jest.fn(), removeHeader: jest.fn(), addTrailers: jest.fn(), flushHeaders: jest.fn(), upgrading,
req,
/* http.ServerResponse */
statusCode,
statusMessage,
assignSocket,
detachSocket,
writeContinue,
writeHead,
writeProcessing,
/* http.OutgoingMessage */
chunkedEncoding,

@@ -44,4 +95,55 @@ shouldKeepAlive,

connection,
socket }, extraProvidedValues);
// express - Response - chainable functions
socket,
setTimeout,
setHeader,
getHeader,
getHeaders,
getHeaderNames,
hasHeader,
removeHeader,
addTrailers,
flushHeaders,
/* stream.Writable */
writable,
writableEnded,
writableFinished,
writableHighWaterMark,
writableLength,
writableObjectMode,
writableCorked,
destroyed,
_write,
_writev,
_destroy,
_final,
write,
setDefaultEncoding,
end,
cork,
uncork,
destroy,
addListener,
emit,
on,
once,
prependListener,
prependOnceListener,
removeListener,
/* event.EventEmitter */
// addListener - is handled/overridden as part of stream.Writable
// on - is handled/overridden as part of stream.Writable
// once - is handled/overridden as part of stream.Writable
// removeListener - is handled/overridden as part of stream.Writable
off,
removeAllListeners,
setMaxListeners,
getMaxListeners,
listeners,
rawListeners,
// emit - is handled/overridden as part of stream.Writable
listenerCount,
// prependListener - is handled/overridden as part of stream.Writable
// prependOnceListener - is handled/overridden as part of stream.Writable
eventNames }, extraProvidedValues);
/* express.Response - chainable functions */
response.status.mockReturnValue(response);

@@ -64,9 +166,27 @@ response.sendStatus.mockReturnValue(response);

response.append.mockReturnValue(response);
// http - ServerResponse - chainable functions
/* http.ServerResponse - chainable functions */
response.writeHead.mockReturnValue(response);
// http - OutgoingMessage - chainable functions
/* http.OutgoingMessage - chainable functions */
response.setTimeout.mockReturnValue(response);
/* stream.Writable - chainable functions */
response.setDefaultEncoding.mockReturnValue(response);
response.addListener.mockReturnValue(response);
response.on.mockReturnValue(response);
response.once.mockReturnValue(response);
response.prependListener.mockReturnValue(response);
response.prependOnceListener.mockReturnValue(response);
response.removeListener.mockReturnValue(response);
/* event.EventEmitter - chainable functions */
// addListener - is handled/overridden as part of stream.Writable
// on - is handled/overridden as part of stream.Writable
// once - is handled/overridden as part of stream.Writable
// removeListener - is handled/overridden as part of stream.Writable
response.off.mockReturnValue(response);
response.removeAllListeners.mockReturnValue(response);
response.setMaxListeners.mockReturnValue(response);
// prependListener - is handled/overridden as part of stream.Writable
// prependOnceListener - is handled/overridden as part of stream.Writable
const clearAllMocks = () => {
next.mockClear();
// express - Response
/* express.Response */
response.status.mockClear();

@@ -95,4 +215,3 @@ response.sendStatus.mockClear();

response.append.mockClear();
// http - ServerResponse
response.end.mockClear();
/* http.ServerResponse */
response.assignSocket.mockClear();

@@ -103,3 +222,3 @@ response.detachSocket.mockClear();

response.writeProcessing.mockClear();
// http - OutgoingMessage
/* http.OutgoingMessage */
response.setTimeout.mockClear();

@@ -114,2 +233,36 @@ response.setHeader.mockClear();

response.flushHeaders.mockClear();
/* stream.Writable */
response._write.mockClear();
response._writev.mockClear();
response._destroy.mockClear();
response._final.mockClear();
response.write.mockClear();
response.setDefaultEncoding.mockClear();
response.end.mockClear();
response.cork.mockClear();
response.uncork.mockClear();
response.destroy.mockClear();
response.addListener.mockClear();
response.emit.mockClear();
response.on.mockClear();
response.once.mockClear();
response.prependListener.mockClear();
response.prependOnceListener.mockClear();
response.removeListener.mockClear();
/* event.EventEmitter */
// addListener - is handled/overridden as part of stream.Writable
// on - is handled/overridden as part of stream.Writable
// once - is handled/overridden as part of stream.Writable
// removeListener - is handled/overridden as part of stream.Writable
response.off.mockClear();
response.removeAllListeners.mockClear();
response.setMaxListeners.mockClear();
response.getMaxListeners.mockClear();
response.listeners.mockClear();
response.rawListeners.mockClear();
// emit - is handled/overridden as part of stream.Writable
response.listenerCount.mockClear();
// prependListener - is handled/overridden as part of stream.Writable
// prependOnceListener - is handled/overridden as part of stream.Writable
response.eventNames.mockClear();
};

@@ -116,0 +269,0 @@ return {

{
"name": "@jest-mock/express",
"version": "1.4.5",
"version": "2.0.0-beta-1",
"description": "A lightweight Jest mock for unit testing Express",

@@ -9,2 +9,3 @@ "main": "dist/index.js",

"test": "jest --coverage",
"test-verbose": "jest --coverage --verbose",
"test-watch": "jest \"/*.ts\" --watchAll",

@@ -15,5 +16,6 @@ "test-watch-all": "jest --watchAll",

"clean": "rm -rf dist/*",
"release": "yarn prepublishOnly && yarn test && yarn lint",
"prepublishOnly": "yarn && yarn clean && yarn build",
"snyk-protect": "snyk protect",
"release": "yarn prepublishOnly && yarn lint && yarn test",
"ci": "yarn release --verbose",
"snyk-protect": "snyk-protect",
"prepare": "yarn run snyk-protect"

@@ -44,14 +46,14 @@ },

"devDependencies": {
"@snyk/protect": "^1.947.0",
"@types/express": "^4.17.13",
"@types/jest": "^26.0.24",
"@typescript-eslint/eslint-plugin": "^4.29.1",
"@typescript-eslint/parser": "^4.29.1",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.4.0",
"jest": "^26.6.3",
"prettier": "^2.3.2",
"snyk": "^1.706.0",
"ts-jest": "^26.5.4",
"typescript": "^4.3.5"
"@types/jest": "^27.5.1",
"@typescript-eslint/eslint-plugin": "^5.27.1",
"@typescript-eslint/parser": "^5.27.1",
"eslint": "^8.17.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.0.0",
"jest": "^27.5.1",
"prettier": "^2.6.2",
"ts-jest": "^27.1.3",
"typescript": "^4.7.3"
},

@@ -58,0 +60,0 @@ "dependencies": {},

// Types
import { MediaType } from 'express-serve-static-core'
import type { IncomingMessage } from 'http'
import type { Readable } from 'stream'
import type { Request } from 'express-serve-static-core'
import type { EventEventEmitter } from 'src'
interface MockIncomingMessage {
aborted?: boolean
httpVersion?: string
httpVersionMajor?: number
httpVersionMinor?: number
complete?: boolean
connection?: any
socket?: any
headers?: any
rawHeaders?: string[]
trailers?: { [key: string]: string | undefined }
rawTrailers?: string[]
setTimeout?: any
statusCode?: number
statusMessage?: string
destroy?: any
interface StreamReadable extends EventEventEmitter {
readable?: Readable['readable']
readableHighWaterMark?: Readable['readableHighWaterMark']
readableLength?: Readable['readableLength']
readableObjectMode?: Readable['readableObjectMode']
destroyed?: Readable['destroyed']
_read?: jest.Mock
read?: jest.Mock
setEncoding?: jest.Mock
pause?: jest.Mock
resume?: jest.Mock
isPaused?: jest.Mock
unpipe?: jest.Mock
unshift?: jest.Mock
wrap?: jest.Mock
push?: jest.Mock
_destroy?: jest.Mock
addListener?: jest.Mock
emit?: jest.Mock
on?: jest.Mock
once?: jest.Mock
prependListener?: jest.Mock
prependOnceListener?: jest.Mock
removeListener?: jest.Mock
destroy?: jest.Mock
}
export interface MockRequest extends MockIncomingMessage {
params?: any
query?: any
body?: any
cookies?: any
method?: string
protocol?: string
secure?: boolean
ip?: string
ips?: string[]
subdomains?: string[]
path?: string
hostname?: string
host?: string
fresh?: boolean
stale?: boolean
xhr?: boolean
route?: any
signedCookies?: any
originalUrl?: string
url?: string
baseUrl?: string
accepted?: MediaType[]
get?: any
header?: any
accepts?: any
acceptsCharsets?: any
acceptsEncodings?: any
acceptsLanguages?: any
range?: any
param?: any
is?: any
app?: any
res?: any
next?: any
interface HttpIncomingMessage extends StreamReadable {
aborted?: IncomingMessage['aborted']
httpVersion?: IncomingMessage['httpVersion']
httpVersionMajor?: IncomingMessage['httpVersionMajor']
httpVersionMinor?: IncomingMessage['httpVersionMinor']
complete?: IncomingMessage['complete']
connection?: Partial<IncomingMessage['connection']>
socket?: Partial<IncomingMessage['socket']>
headers?: Partial<IncomingMessage['headers']>
rawHeaders?: IncomingMessage['rawHeaders']
trailers?: IncomingMessage['trailers']
rawTrailers?: IncomingMessage['rawTrailers']
setTimeout?: jest.Mock
statusCode?: IncomingMessage['statusCode']
statusMessage?: IncomingMessage['statusMessage']
destroy?: jest.Mock
}
export interface MockRequest extends HttpIncomingMessage {
params?: Request['params']
query?: Request['query']
body?: Request['body']
cookies?: Request['cookies']
method?: Request['method']
protocol?: Request['protocol']
secure?: Request['secure']
ip?: Request['ip']
ips?: Request['ips']
subdomains?: Request['subdomains']
path?: Request['path']
hostname?: Request['hostname']
host?: Request['host']
fresh?: Request['fresh']
stale?: Request['stale']
xhr?: Request['xhr']
route?: Request['route']
signedCookies?: Request['signedCookies']
originalUrl?: Request['originalUrl']
url?: Request['url']
baseUrl?: Request['baseUrl']
accepted?: Request['accepted']
get?: jest.Mock
header?: jest.Mock
accepts?: jest.Mock
acceptsCharsets?: jest.Mock
acceptsEncodings?: jest.Mock
acceptsLanguages?: jest.Mock
range?: jest.Mock
param?: jest.Mock
is?: jest.Mock
app?: Partial<Request['app']>
res?: Partial<Request['res']>
next?: jest.Mock
// allow custom properties to be provided
// eslint-disable-next-line @typescript-eslint/no-explicit-any
[key: string]: any
}

@@ -12,2 +12,3 @@ // Libraries

const {
/* express.Request */
params = {},

@@ -47,2 +48,4 @@ query = {},

next = jest.fn().mockName('next mock default'),
/* http.IncomingMessage */
aborted = false,

@@ -63,6 +66,52 @@ httpVersion = '',

destroy = jest.fn().mockName('destroy mock default'),
/* stream.Readable */
readable = false,
readableHighWaterMark = 0,
readableLength = 0,
readableObjectMode = false,
destroyed = false,
_read = jest.fn().mockName('_read mock default'),
read = jest.fn().mockName('read mock default'),
setEncoding = jest.fn().mockName('setEncoding mock default'),
pause = jest.fn().mockName('pause mock default'),
resume = jest.fn().mockName('resume mock default'),
isPaused = jest.fn().mockName('isPaused mock default'),
unpipe = jest.fn().mockName('unpipe mock default'),
unshift = jest.fn().mockName('unshift mock default'),
wrap = jest.fn().mockName('wrap mock default'),
push = jest.fn().mockName('push mock default'),
_destroy = jest.fn().mockName('_destroy mock default'),
addListener = jest.fn().mockName('addListener mock default'),
emit = jest.fn().mockName('emit mock default'),
on = jest.fn().mockName('on mock default'),
once = jest.fn().mockName('once mock default'),
prependListener = jest.fn().mockName('prependListener mock default'),
prependOnceListener = jest.fn().mockName('prependOnceListener mock default'),
removeListener = jest.fn().mockName('removeListener mock default'),
// destroy - is handled/overridden as part of http.IncomingMessage
/* event.EventEmitter */
// addListener - is handled/overridden as part of stream.Readable
// on - is handled/overridden as part of stream.Readable
// once - is handled/overridden as part of stream.Readable
// removeListener - is handled/overridden as part of stream.Readable
off = jest.fn().mockName('off mock default'),
removeAllListeners = jest.fn().mockName('removeAllListeners mock default'),
setMaxListeners = jest.fn().mockName('setMaxListeners mock default'),
getMaxListeners = jest.fn().mockName('getMaxListeners mock default'),
listeners = jest.fn().mockName('listeners mock default'),
rawListeners = jest.fn().mockName('rawListeners mock default'),
// emit - is handled/overridden as part of stream.Readable
listenerCount = jest.fn().mockName('listenerCount mock default'),
// prependListener - is handled/overridden as part of stream.Readable
// prependOnceListener - is handled/overridden as part of stream.Readable
eventNames = jest.fn().mockName('eventNames mock default'),
// custom values
...extraProvidedValues
} = values
return {
const request = {
/* express.Request */
params,

@@ -103,3 +152,3 @@ query,

// http - IncomingMessage
/* http.IncomingMessage */
aborted,

@@ -121,7 +170,52 @@ httpVersion,

/* stream.Readable */
readable,
readableHighWaterMark,
readableLength,
readableObjectMode,
destroyed,
_read,
read,
setEncoding,
pause,
resume,
isPaused,
unpipe,
unshift,
wrap,
push,
_destroy,
addListener,
emit,
on,
once,
prependListener,
prependOnceListener,
removeListener,
// destroy - is handled/overridden as part of http.IncomingMessage
/* event.EventEmitter */
// addListener - is handled/overridden as part of stream.Readable
// on - is handled/overridden as part of stream.Readable
// once - is handled/overridden as part of stream.Readable
// removeListener - is handled/overridden as part of stream.Readable
off,
removeAllListeners,
setMaxListeners,
getMaxListeners,
listeners,
rawListeners,
// emit - is handled/overridden as part of stream.Readable
listenerCount,
// prependListener - is handled/overridden as part of stream.Readable
// prependOnceListener - is handled/overridden as part of stream.Readable
eventNames,
// custom values
...extraProvidedValues,
} as T
}
return request as unknown as T
}
export default getMockReq

@@ -1,19 +0,99 @@

export interface MockResponse {
headersSent?: boolean
charset?: string
req?: any
app?: any
locals?: any
statusCode?: number
statusMessage?: string
upgrading?: boolean
chunkedEncoding?: boolean
shouldKeepAlive?: boolean
useChunkedEncodingByDefault?: boolean
sendDate?: boolean
finished?: boolean
connection?: any
socket?: any
// Types
import type { ServerResponse, OutgoingMessage, IncomingMessage } from 'http'
import type { Writable } from 'stream'
import type { Response } from 'express'
import type { EventEventEmitter } from 'src'
interface StreamWritable extends EventEventEmitter {
writable?: Writable['writable']
writableEnded?: Writable['writableEnded']
writableFinished?: Writable['writableFinished']
writableHighWaterMark?: Writable['writableHighWaterMark']
writableLength?: Writable['writableLength']
writableObjectMode?: Writable['writableObjectMode']
writableCorked?: Writable['writableCorked']
destroyed?: Writable['destroyed']
_write?: jest.Mock
_writev?: jest.Mock
_destroy?: jest.Mock
_final?: jest.Mock
write?: jest.Mock
setDefaultEncoding?: jest.Mock
end?: jest.Mock
cork?: jest.Mock
uncork?: jest.Mock
destroy?: jest.Mock
addListener?: jest.Mock
emit?: jest.Mock
on?: jest.Mock
once?: jest.Mock
prependListener?: jest.Mock
prependOnceListener?: jest.Mock
removeListener?: jest.Mock
}
interface HttpOutgoingMessage extends StreamWritable {
req?: Partial<IncomingMessage>
chunkedEncoding?: OutgoingMessage['chunkedEncoding']
shouldKeepAlive?: OutgoingMessage['shouldKeepAlive']
useChunkedEncodingByDefault?: OutgoingMessage['useChunkedEncodingByDefault']
sendDate?: OutgoingMessage['sendDate']
finished?: OutgoingMessage['finished']
headersSent?: OutgoingMessage['headersSent']
connection?: Partial<OutgoingMessage['connection']>
socket?: Partial<OutgoingMessage['socket']>
setTimeout?: jest.Mock
setHeader?: jest.Mock
getHeader?: jest.Mock
getHeaders?: jest.Mock
getHeaderNames?: jest.Mock
hasHeader?: jest.Mock
removeHeader?: jest.Mock
addTrailers?: jest.Mock
flushHeaders?: jest.Mock
}
interface HttpServerResponse extends HttpOutgoingMessage {
statusCode?: ServerResponse['statusCode']
statusMessage?: ServerResponse['statusMessage']
assignSocket?: jest.Mock
detachSocket?: jest.Mock
writeContinue?: jest.Mock
writeHead?: jest.Mock
writeProcessing?: jest.Mock
}
export interface MockResponse extends HttpServerResponse {
status?: jest.Mock
sendStatus?: jest.Mock
links?: jest.Mock
send?: jest.Mock
json?: jest.Mock
jsonp?: jest.Mock
sendFile?: jest.Mock
sendfile?: jest.Mock
download?: jest.Mock
contentType?: jest.Mock
type?: jest.Mock
format?: jest.Mock
attachment?: jest.Mock
set?: jest.Mock
header?: jest.Mock
headersSent?: Response['headersSent']
get?: jest.Mock
clearCookie?: jest.Mock
cookie?: jest.Mock
location?: jest.Mock
redirect?: jest.Mock
render?: jest.Mock
locals?: Partial<Response['locals']>
charset?: Response['charset']
vary?: jest.Mock
app?: Partial<Response['app']>
append?: jest.Mock
req?: Partial<Response['req']>
// allow custom properties to be provided
// eslint-disable-next-line @typescript-eslint/no-explicit-any
[key: string]: any
}

@@ -24,10 +24,43 @@ // Libraries

const {
/* express.Response */
status = jest.fn().mockName('status mock default'),
sendStatus = jest.fn().mockName('sendStatus mock default'),
links = jest.fn().mockName('links mock default'),
send = jest.fn().mockName('send mock default'),
json = jest.fn().mockName('json mock default'),
jsonp = jest.fn().mockName('jsonp mock default'),
sendFile = jest.fn().mockName('sendFile mock default'),
sendfile = jest.fn().mockName('sendfile mock default'),
download = jest.fn().mockName('download mock default'),
contentType = jest.fn().mockName('contentType mock default'),
type = jest.fn().mockName('type mock default'),
format = jest.fn().mockName('format mock default'),
attachment = jest.fn().mockName('attachment mock default'),
set = jest.fn().mockName('set mock default'),
header = jest.fn().mockName('header mock default'),
headersSent = false,
get = jest.fn().mockName('get mock default'),
clearCookie = jest.fn().mockName('clearCookie mock default'),
cookie = jest.fn().mockName('cookie mock default'),
location = jest.fn().mockName('location mock default'),
redirect = jest.fn().mockName('redirect mock default'),
render = jest.fn().mockName('render mock default'),
locals = {},
charset = '',
vary = jest.fn().mockName('vary mock default'),
app = {},
append = jest.fn().mockName('append mock default'),
req = {},
/* http.ServerResponse */
statusCode = 0,
statusMessage = '',
upgrading = false,
assignSocket = jest.fn().mockName('assignSocket mock default'),
detachSocket = jest.fn().mockName('detachSocket mock default'),
writeContinue = jest.fn().mockName('writeContinue mock default'),
writeHead = jest.fn().mockName('writeHead mock default'),
writeProcessing = jest.fn().mockName('writeProcessing mock default'),
/* http.OutgoingMessage */
// req - is handled/overridden as part of express.Response
chunkedEncoding = false,

@@ -38,31 +71,88 @@ shouldKeepAlive = false,

finished = false,
// headersSent - is handled/overridden as part of express.Response
connection = {},
socket = {},
setTimeout = jest.fn().mockName('setTimeout mock default'),
setHeader = jest.fn().mockName('setHeader mock default'),
getHeader = jest.fn().mockName('getHeader mock default'),
getHeaders = jest.fn().mockName('getHeaders mock default'),
getHeaderNames = jest.fn().mockName('getHeaderNames mock default'),
hasHeader = jest.fn().mockName('hasHeader mock default'),
removeHeader = jest.fn().mockName('removeHeader mock default'),
addTrailers = jest.fn().mockName('addTrailers mock default'),
flushHeaders = jest.fn().mockName('flushHeaders mock default'),
/* stream.Writable */
writable = false,
writableEnded = false,
writableFinished = false,
writableHighWaterMark = 0,
writableLength = 0,
writableObjectMode = false,
writableCorked = 0,
destroyed = false,
_write = jest.fn().mockName('_write mock default'),
_writev = jest.fn().mockName('_writev mock default'),
_destroy = jest.fn().mockName('_destroy mock default'),
_final = jest.fn().mockName('_final mock default'),
write = jest.fn().mockName('write mock default'),
setDefaultEncoding = jest.fn().mockName('setDefaultEncoding mock default'),
end = jest.fn().mockName('end mock default'),
cork = jest.fn().mockName('cork mock default'),
uncork = jest.fn().mockName('uncork mock default'),
destroy = jest.fn().mockName('destroy mock default'),
addListener = jest.fn().mockName('addListener mock default'),
emit = jest.fn().mockName('emit mock default'),
on = jest.fn().mockName('on mock default'),
once = jest.fn().mockName('once mock default'),
prependListener = jest.fn().mockName('prependListener mock default'),
prependOnceListener = jest.fn().mockName('prependOnceListener mock default'),
removeListener = jest.fn().mockName('removeListener mock default'),
/* event.EventEmitter */
// addListener - is handled/overridden as part of stream.Writable
// on - is handled/overridden as part of stream.Writable
// once - is handled/overridden as part of stream.Writable
// removeListener - is handled/overridden as part of stream.Writable
off = jest.fn().mockName('off mock default'),
removeAllListeners = jest.fn().mockName('removeAllListeners mock default'),
setMaxListeners = jest.fn().mockName('setMaxListeners mock default'),
getMaxListeners = jest.fn().mockName('getMaxListeners mock default'),
listeners = jest.fn().mockName('listeners mock default'),
rawListeners = jest.fn().mockName('rawListeners mock default'),
// emit - is handled/overridden as part of stream.Writable
listenerCount = jest.fn().mockName('listenerCount mock default'),
// prependListener - is handled/overridden as part of stream.Writable
// prependOnceListener - is handled/overridden as part of stream.Writable
eventNames = jest.fn().mockName('eventNames mock default'),
// custom values
...extraProvidedValues
} = values
const response = {
// express - Response
status: jest.fn(),
sendStatus: jest.fn(),
links: jest.fn(),
send: jest.fn(),
json: jest.fn(),
jsonp: jest.fn(),
sendFile: jest.fn(),
sendfile: jest.fn(),
download: jest.fn(),
contentType: jest.fn(),
type: jest.fn(),
format: jest.fn(),
attachment: jest.fn(),
set: jest.fn(),
header: jest.fn(),
get: jest.fn(),
clearCookie: jest.fn(),
cookie: jest.fn(),
location: jest.fn(),
redirect: jest.fn(),
render: jest.fn(),
vary: jest.fn(),
append: jest.fn(),
/* express.Response */
status,
sendStatus,
links,
send,
json,
jsonp,
sendFile,
sendfile,
download,
contentType,
type,
format,
attachment,
set,
header,
get,
clearCookie,
cookie,
location,
redirect,
render,
vary,
append,
headersSent,

@@ -73,22 +163,13 @@ locals,

req,
// http - ServerResponse
end: jest.fn(),
assignSocket: jest.fn(),
detachSocket: jest.fn(),
writeContinue: jest.fn(),
writeHead: jest.fn(),
writeProcessing: jest.fn(),
/* http.ServerResponse */
statusCode,
statusMessage,
// http - OutgoingMessage
setTimeout: jest.fn(),
setHeader: jest.fn(),
getHeader: jest.fn(),
getHeaders: jest.fn(),
getHeaderNames: jest.fn(),
hasHeader: jest.fn(),
removeHeader: jest.fn(),
addTrailers: jest.fn(),
flushHeaders: jest.fn(),
upgrading,
assignSocket,
detachSocket,
writeContinue,
writeHead,
writeProcessing,
/* http.OutgoingMessage */
chunkedEncoding,

@@ -101,2 +182,56 @@ shouldKeepAlive,

socket,
setTimeout,
setHeader,
getHeader,
getHeaders,
getHeaderNames,
hasHeader,
removeHeader,
addTrailers,
flushHeaders,
/* stream.Writable */
writable,
writableEnded,
writableFinished,
writableHighWaterMark,
writableLength,
writableObjectMode,
writableCorked,
destroyed,
_write,
_writev,
_destroy,
_final,
write,
setDefaultEncoding,
end,
cork,
uncork,
destroy,
addListener,
emit,
on,
once,
prependListener,
prependOnceListener,
removeListener,
/* event.EventEmitter */
// addListener - is handled/overridden as part of stream.Writable
// on - is handled/overridden as part of stream.Writable
// once - is handled/overridden as part of stream.Writable
// removeListener - is handled/overridden as part of stream.Writable
off,
removeAllListeners,
setMaxListeners,
getMaxListeners,
listeners,
rawListeners,
// emit - is handled/overridden as part of stream.Writable
listenerCount,
// prependListener - is handled/overridden as part of stream.Writable
// prependOnceListener - is handled/overridden as part of stream.Writable
eventNames,
// custom values

@@ -106,3 +241,3 @@ ...extraProvidedValues,

// express - Response - chainable functions
/* express.Response - chainable functions */
response.status.mockReturnValue(response)

@@ -125,10 +260,32 @@ response.sendStatus.mockReturnValue(response)

response.append.mockReturnValue(response)
// http - ServerResponse - chainable functions
/* http.ServerResponse - chainable functions */
response.writeHead.mockReturnValue(response)
// http - OutgoingMessage - chainable functions
/* http.OutgoingMessage - chainable functions */
response.setTimeout.mockReturnValue(response)
/* stream.Writable - chainable functions */
response.setDefaultEncoding.mockReturnValue(response)
response.addListener.mockReturnValue(response)
response.on.mockReturnValue(response)
response.once.mockReturnValue(response)
response.prependListener.mockReturnValue(response)
response.prependOnceListener.mockReturnValue(response)
response.removeListener.mockReturnValue(response)
/* event.EventEmitter - chainable functions */
// addListener - is handled/overridden as part of stream.Writable
// on - is handled/overridden as part of stream.Writable
// once - is handled/overridden as part of stream.Writable
// removeListener - is handled/overridden as part of stream.Writable
response.off.mockReturnValue(response)
response.removeAllListeners.mockReturnValue(response)
response.setMaxListeners.mockReturnValue(response)
// prependListener - is handled/overridden as part of stream.Writable
// prependOnceListener - is handled/overridden as part of stream.Writable
const clearAllMocks = (): void => {
next.mockClear()
// express - Response
/* express.Response */
response.status.mockClear()

@@ -157,4 +314,4 @@ response.sendStatus.mockClear()

response.append.mockClear()
// http - ServerResponse
response.end.mockClear()
/* http.ServerResponse */
response.assignSocket.mockClear()

@@ -165,3 +322,4 @@ response.detachSocket.mockClear()

response.writeProcessing.mockClear()
// http - OutgoingMessage
/* http.OutgoingMessage */
response.setTimeout.mockClear()

@@ -176,2 +334,38 @@ response.setHeader.mockClear()

response.flushHeaders.mockClear()
/* stream.Writable */
response._write.mockClear()
response._writev.mockClear()
response._destroy.mockClear()
response._final.mockClear()
response.write.mockClear()
response.setDefaultEncoding.mockClear()
response.end.mockClear()
response.cork.mockClear()
response.uncork.mockClear()
response.destroy.mockClear()
response.addListener.mockClear()
response.emit.mockClear()
response.on.mockClear()
response.once.mockClear()
response.prependListener.mockClear()
response.prependOnceListener.mockClear()
response.removeListener.mockClear()
/* event.EventEmitter */
// addListener - is handled/overridden as part of stream.Writable
// on - is handled/overridden as part of stream.Writable
// once - is handled/overridden as part of stream.Writable
// removeListener - is handled/overridden as part of stream.Writable
response.off.mockClear()
response.removeAllListeners.mockClear()
response.setMaxListeners.mockClear()
response.getMaxListeners.mockClear()
response.listeners.mockClear()
response.rawListeners.mockClear()
// emit - is handled/overridden as part of stream.Writable
response.listenerCount.mockClear()
// prependListener - is handled/overridden as part of stream.Writable
// prependOnceListener - is handled/overridden as part of stream.Writable
response.eventNames.mockClear()
}

@@ -178,0 +372,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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