Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

[bug] Retry + assert in async scenario does not work

未关闭
#2,892 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
javascript, node.js, playwright
领域
testing-qa

调研方向

使用 CodeceptJS 3.0.5 或 3.0.6、Node.js 14.16.1 和 Playwright 重现 issue 中的两个 async 场景,并比较有 retry 和无 retry 的运行结果。从该重现中跟踪 async 场景的 retry 处理;完成的标准是意外的 assertion 在 retry 后仍然是测试失败,并且最终输出报告一个失败的测试。

由索引模型根据 Issue 内容生成。

描述

bug
What are you trying to achieve?

Assertion like the doc example (but with an unexpected value in the assertion):

const assert = require('assert')

Scenario.only('test page title 1', async ({ I }) => {
  I.amOnPage('https://www.google.com')
  const title = await I.grabTitle()
  assert.strictEqual(title, 'Bad value')
}).retry(2)

Scenario('test page title 2', { retry: 2 }, async ({ I }) => {
  I.amOnPage('https://www.google.com')
  const title = await I.grabTitle()
  assert.strictEqual(title, 'Bad value')
})
What do you get instead?

With retry option, the test does not fail (ok at the end), it's unexpected:

> codeceptjs run --steps "--verbose"

CodeceptJS v3.0.5
Using test root "---"
Helpers: Playwright, Context, Network
Plugins: screenshotOnFail, retryFailedStep, tryTo

US checkout / LP0001 --
    [1]  Starting recording promises
 › [Session] Starting singleton browser session
  test page title 1
    I am on page "https://www.google.com"
    I grab title
    [1] Error | AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
+ actual - expected

+ 'Google'
- 'Bad value'
    [1] Starting <teardown> session
    [1] <teardown> Stopping recording promises
 › <screenshotOnFail> Test failed, try to save a screenshot
 › Screenshot is saving to /----/codecept/output/test_page_title_1.failed.png
    [2]  Starting recording promises
 › [Session] cleaning cookies and localStorage

  OK  | 0 passed   // 2s

Without the retry, it's good, the test fails as expected:

> lv-front@1.0.2 codecept
> codeceptjs run --steps

CodeceptJS v3.0.5
Using test root "-----"

US checkout / LP0001 --
  test page title 1
    I am on page "https://www.google.com"
    I grab title
  ✖ FAILED in 1059ms


-- FAILURES:

  1) US checkout / LP0001
       test page title 1:

      Expected values to be strictly equal:
+ actual - expected

+ 'Google'
- 'Bad value'
      + expected - actual

      -Google
      +Bad value

  AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
  + actual - expected



  Artifacts:
  - screenshot: /----/codecept/output/test_page_title_1.failed.png


  FAIL  | 0 passed, 1 failed   // 1s
Details
  • CodeceptJS version: 3.0.5 (but 3.0.6 tested too with the same bug)
  • NodeJS Version: 14.16.1
  • Operating System: macosX
  • playwright
主要语言
JavaScript
星标
4.2k
派生
756
平均合并
2 天 9 小时
30 天内合并 PR
16

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

codeceptjs/CodeceptJS 的其他 Issue

查看 codeceptjs/CodeceptJS 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。