* 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 = {})
| 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. |
no test coverage detected