MCPcopy Index your code
hub / github.com/codeceptjs/CodeceptJS / seeResponseContainsKeys

Method seeResponseContainsKeys

lib/helper/JSONResponse.js:245–258  ·  view source on GitHub ↗

* Checks for deep inclusion of a provided json in a response data. * * ```js * // response.data == { user: { name: 'jon', email: 'jon@doe.com' } } * * I.seeResponseContainsKeys(['user']); * ``` * * If an array is received, check is performed for each element of array: *

(keys = [])

Source from the content-addressed store, hash-verified

243 * @param {array} keys
244 */
245 seeResponseContainsKeys(keys = []) {
246 this._checkResponseReady()
247 if (Array.isArray(this.response.data)) {
248 for (const data of this.response.data) {
249 for (const key of keys) {
250 assert(key in data, `Key "${key}" is not found in ${JSON.stringify(data)}`)
251 }
252 }
253 } else {
254 for (const key of keys) {
255 assert(key in this.response.data, `Key "${key}" is not found in ${JSON.stringify(this.response.data)}`)
256 }
257 }
258 }
259
260 /**
261 * Executes a callback function passing in `response` object and assert

Callers 3

REST_test.jsFile · 0.80
GraphQL_test.jsFile · 0.80

Calls 1

_checkResponseReadyMethod · 0.95

Tested by

no test coverage detected