* @param {Chai.ChaiStatic} chai * @param {Chai.ChaiUtils} utils
(chai, utils)
| 268 | * @param {Chai.ChaiUtils} utils |
| 269 | */ |
| 270 | function installBrowserWrappers(chai, utils) { |
| 271 | const {Assertion} = chai; |
| 272 | |
| 273 | // Assert that a request with a testUrl was sent |
| 274 | // Example usage: await expect(testUrl).to.have.been.sent; |
| 275 | utils.addProperty(Assertion.prototype, 'sent', async function () { |
| 276 | // @ts-ignore |
| 277 | const that = this; |
| 278 | const url = that._obj; |
| 279 | const requests = await networkLogger.getSentRequests(url); |
| 280 | that.assert(0 < requests.length, 'expected #{this} to have been sent'); |
| 281 | }); |
| 282 | Assertion.overwriteProperty( |
| 283 | 'sent', |
| 284 | /** @type {any} */ (overwriteAlwaysUseSuper(utils)) |
| 285 | ); |
| 286 | |
| 287 | // Assert that a request was sent n number of times |
| 288 | // Example usage: await expect(testUrl).to.have.sentCount(n); |
| 289 | utils.addMethod(Assertion.prototype, 'sentCount', async function (count) { |
| 290 | // @ts-ignore |
| 291 | const that = this; |
| 292 | const url = that._obj; |
| 293 | const requests = await networkLogger.getSentRequests(url); |
| 294 | that.assert( |
| 295 | count === requests.length, |
| 296 | `expected #{this} to have been sent ${ |
| 297 | count == 1 ? 'once' : count + ' times' |
| 298 | }` |
| 299 | ); |
| 300 | }); |
| 301 | Assertion.overwriteMethod('sentCount', overwriteAlwaysUseSuper(utils)); |
| 302 | } |
| 303 | |
| 304 | module.exports = { |
| 305 | clearLastExpectError, |
nothing calls this directly
no test coverage detected