Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

step.duration reflects only the last retry attempt (HelperStep.run() overwrites startTime)

已關閉 適合新手
#5,774 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 2 天內回覆

@mirao 已經在處理了。

開始於 2026年10月30日。

  • #5775 來自 @mirao —— 未關閉

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
78/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
javascript, nodejs, playwright
領域
backend, testing

研究方向

從 lib/step/helper.js 和 lib/step/func.js 開始,查看 run() 重設 startTime 的位置,接著比較它們與 lib/step/record.js 中防護條件的行為。檢查 lib/step/base.js 中 duration 的計算方式,並尋找現有的重試測試。完成標準是:duration 涵蓋從第一次嘗試到最終通過或失敗的整個過程。

由索引模型根據 Issue 內容生成。

描述

What happens

When a helper step is retried (e.g. by the retryFailedStep plugin), step.duration covers only the last attempt instead of the whole step.

In our run, a I.click(...) step was retried for ~50 seconds before it finally failed. The HTML report (@testomatio/reporter, which shows step.duration) listed it as 3ms, while the scenario took 49s 697ms.

Cause

lib/step/record.js deliberately keeps the start time of the first attempt:

() => {
  if (!step.startTime) {
    // step can be retries
    event.emit(event.step.started, step)
    step.startTime = +Date.now()
  }
  return (val = step.run(...args))
},

But HelperStep.run() in lib/step/helper.js overwrites it on every attempt:

run() {
  this.args = Array.prototype.slice.call(arguments)
  this.startTime = +Date.now()
  ...

So duration (endTime - startTime in lib/step/base.js) is measured from the start of the last retry. FuncStep.run() in lib/step/func.js has the same assignment.

Expected

step.duration covers all attempts, from the first start to the final pass or failure, as the guard in record.js intends. A possible fix is to set startTime in run() only when it isn't already set.

Steps to reproduce
  1. Enable retryFailedStep.
  2. Run a step that fails for a while and is retried, e.g. I.click() on an element that never shows up.
  3. Read step.duration in an event.step.finished listener, or look at the step time in any reporter that uses it. It shows only the last attempt's duration (a few ms).
Environment
  • CodeceptJS 4.2.2 (also present on current main)
  • Playwright helper, Bun runtime

Created by AI agent (Claude Code)

主要語言
JavaScript
星號
4.2k
分支
754
平均合併
2 天 6 小時
30 天內合併 PR
33

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

codeceptjs/CodeceptJS 的其他 Issue

查看 codeceptjs/CodeceptJS 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。