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

Method dontSeeResponseContainsJson

lib/helper/JSONResponse.js:204–224  ·  view source on GitHub ↗

* Checks for deep inclusion of a provided json in a response data. * * ```js * // response.data == { data: { user: 1 } } * * I.dontSeeResponseContainsJson({ user: 2 }); * ``` * If an array is received, checks that no element of array contains json: * ```js * // response.da

(json = {})

Source from the content-addressed store, hash-verified

202 * @param {object} json
203 */
204 dontSeeResponseContainsJson(json = {}) {
205 this._checkResponseReady()
206 if (Array.isArray(this.response.data)) {
207 for (const data of this.response.data) {
208 try {
209 this._assertContains(data, json)
210 assert.fail(`Found matching element: ${JSON.stringify(data)}`)
211 } catch (err) {
212 // expected to fail
213 continue
214 }
215 }
216 } else {
217 try {
218 this._assertContains(this.response.data, json)
219 assert.fail('Response contains the JSON')
220 } catch (err) {
221 // expected to fail
222 }
223 }
224 }
225
226 /**
227 * Checks for deep inclusion of a provided json in a response data.

Callers 1

Calls 3

_checkResponseReadyMethod · 0.95
_assertContainsMethod · 0.95
failMethod · 0.80

Tested by

no test coverage detected