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

Chiusa Adatta ai principianti
#5,774 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

@mirao ci sta già lavorando.

Dal 30/10/2026.

  • #5775 di @mirao — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
javascript, nodejs, playwright
Ambito
backend, testing

Direzione di ricerca

Inizia da lib/step/helper.js e lib/step/func.js, dove run() reimposta startTime, poi confronta il loro comportamento con la condizione di guardia in lib/step/record.js. Controlla come viene calcolato duration in lib/step/base.js e cerca i test di retry esistenti. Il lavoro è completato quando la durata copre il periodo dal primo tentativo fino al successo o al fallimento finale.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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)

Lingua principale
JavaScript
Stelle
4.2k
Fork
754
Merge medio
2g 6h
PR unite (30g)
33

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di codeceptjs/CodeceptJS

Tutte le issue di codeceptjs/CodeceptJS

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.