( context: HandlerContextStub, requestOptions: ShotRequestOptions, )
| 146 | } |
| 147 | |
| 148 | function 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'. |
no test coverage detected