簡體   English   中英

對賽普拉斯測試重試執行自定義操作

[英]Perform custom actions on Cypress test retry

我在賽普拉斯測試中使用重試。 每次重試測試時,我都想執行一個操作(例如,在文件中記錄有關失敗的詳細信息)。

我認為command:retry 事件目錄中的重試可能有用,但我不確定該參數是什么意思以及如何使用它。

有一個cyclope插件可能涵蓋了您想要對測試失敗執行的操作。 該插件包含一個實用工具 function savePageIfTestFailed ,您可以在support/index.js文件中的afterEach()中調用它。

你可能會發現command:retry有點太細化了,試試on fail事件。

Cypress.on('fail', (error, runnable) => {
  debugger
  
  // take a look at the parameters
  console.log('error', error.message)
  console.log('runnable', runnable)

  // for example
  let currentTest = runnable.ctx.currentTest
  let title = runnable.title

  throw error // throw error to have test still fail
})

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM