Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

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

Aberta Para iniciantes
#5,774 1 comentário 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 2 dias

@mirao já está trabalhando nisso.

Desde 30/10/2026.

  • #5775 de @mirao — aberto

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
78/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
javascript, nodejs, playwright
Domínio
backend, testing

Direção de pesquisa

Comece por lib/step/helper.js e lib/step/func.js, onde run() redefine startTime, depois compare o comportamento deles com a condição de proteção em lib/step/record.js. Verifique como duration é calculada em lib/step/base.js e procure testes de retry existentes. O trabalho estará concluído quando a duração abranger desde a primeira tentativa até o sucesso ou a falha final.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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)

Linguagem predominante
JavaScript
Estrelas
4.2k
Forks
754
Merge médio
2d 11h
PRs com merge (30d)
33

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de codeceptjs/CodeceptJS

Todas as issues de codeceptjs/CodeceptJS

Issues semelhantes

Mais issues de JavaScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.