MCPcopy Index your code
hub / github.com/loopbackio/loopback-next / defineCustomContextInspect

Function defineCustomContextInspect

packages/testlab/src/shot.ts:148–178  ·  view source on GitHub ↗
(
  context: HandlerContextStub,
  requestOptions: ShotRequestOptions,
)

Source from the content-addressed store, hash-verified

146}
147
148function defineCustomContextInspect(
149 context: HandlerContextStub,
150 requestOptions: ShotRequestOptions,
151) {
152 // Setup custom inspect functions to make test error messages easier to read
153 const inspectOpts = (depth: number, opts: any) =>
154 util.inspect(requestOptions, opts);
155
156 defineCustomInspect(
157 context.request,
158 (depth, opts) => `[RequestStub with options ${inspectOpts(depth, opts)}]`,
159 );
160
161 defineCustomInspect(
162 context.response,
163 (depth, opts) =>
164 `[ResponseStub for request with options ${inspectOpts(depth, opts)}]`,
165 );
166
167 context.result = context.result.then(r => {
168 defineCustomInspect(
169 r,
170 (depth, opts) =>
171 `[ObservedResponse for request with options ${inspectOpts(
172 depth,
173 opts,
174 )}]`,
175 );
176 return r;
177 });
178}
179
180// @types/node@v10.17.29 seems to miss the type definition of `util.inspect.custom`
181// error TS2339: Property 'custom' does not exist on type 'typeof inspect'.

Callers 2

stubHandlerContextFunction · 0.85
stubExpressContextFunction · 0.85

Calls 2

defineCustomInspectFunction · 0.85
inspectOptsFunction · 0.85

Tested by

no test coverage detected