0

テスト ケースが失敗したときに、追加のデータをログに記録したいと考えています。カスタム エラー ハンドラをどこに挿入するのが最適ですか?

例えば:

cy.get('something')
  .should('have.property', 'blah')

Cypress ダッシュボードでこれが失敗すると、次のようになります。

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}

最終的に、いくつかの追加のコンテキスト データをログに記録したいので、テストが失敗/フレークする理由を調査およびデバッグできます。

4

1 に答える 1