当测试用例失败时,我想记录额外的数据。我在哪里可以最好地插入我的自定义错误处理程序?
例如:
cy.get('something')
.should('have.property', 'blah')
当这在赛普拉斯仪表板中失败时,我得到:
CypressError: Timed out retrying: expected 'something' to have a property 'blah'
at Object.cypressErr (https://my.website.com/__cypress/runner/cypress_runner.js:65727:11)
at Object.throwErr (https://my.website.com/__cypress/runner/cypress_runner.js:65692:18)
at Object.throwErrByPath (https://my.website.com/__cypress/runner/cypress_runner.js:65719:17)
at retry (https://my.website.com/__cypress/runner/cypress_runner.js:59237:16)
at https://my.website.com/__cypress/runner/cypress_runner.js:51312:18
at tryCatcher (https://my.website.com/__cypress/runner/cypress_runner.js:131273:23)
at Promise._settlePromiseFromHandler (https://my.website.com/__cypress/runner/cypress_runner.js:129291:31)
at Promise._settlePromise (https://my.website.com/__cypress/runner/cypress_runner.js:129348:18)
at Promise._settlePromise0 (https://my.website.com/__cypress/runner/cypress_runner.js:129393:10)
at Promise._settlePromises (https://my.website.com/__cypress/runner/cypress_runner.js:129468:18)
at Async._drainQueue (https://my.website.com/__cypress/runner/cypress_runner.js:126197:16)
at Async._drainQueues (https://my.website.com/__cypress/runner/cypress_runner.js:126207:10)
at Async.drainQueues (https://my.website.com/__cypress/runner/cypress_runner.js:126081:14)
at <anonymous>
我可以做些什么来自定义这个错误,比如:
CypressError: ...
My additional logging: {foo: 'bar', etc, etc}
最终,我想记录一些额外的上下文数据,这样我就可以调查 + 调试为什么测试可能会失败/失败。