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

Method seeResponseContainsJson

lib/helper/JSONResponse.js:168–185  ·  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.seeResponseContainsJson({ user: { email: 'jon@doe.com' } }); * ``` * If an array is received, checks that at least one element

(json = {})

Source from the content-addressed store, hash-verified

166 * @param {object} json
167 */
168 seeResponseContainsJson(json = {}) {
169 this._checkResponseReady()
170 if (Array.isArray(this.response.data)) {
171 let found = false
172 for (const el of this.response.data) {
173 try {
174 this._assertContains(el, json)
175 found = true
176 break
177 } catch (err) {
178 continue
179 }
180 }
181 assert(found, `No elements in array matched ${JSON.stringify(json)}`)
182 } else {
183 this._assertContains(this.response.data, json)
184 }
185 }
186
187 /**
188 * Checks for deep inclusion of a provided json in a response data.

Callers 2

GraphQL_test.jsFile · 0.80

Calls 2

_checkResponseReadyMethod · 0.95
_assertContainsMethod · 0.95

Tested by

no test coverage detected