Cypress重试全局配置不起作用。

huangapple go评论53阅读模式
英文:

Cypress Retries global configuration doesnt work

问题

我在Cypress中遇到了关于重试的问题。
我还使用了fail-fast插件,而且它工作得很完美。
我已经根据官方文档在我的cypress.config.ts配置中将重试选项添加为全局配置

一切都运行得很顺利,包括HTML报告、快速失败等,但重试却没有生效,不知道为什么。我已经查阅了官方文档很多次,还查看了快速失败文档,以防它对重试产生了影响,但没有找到太多信息。

当在运行模式下出现错误时,即使配置了2次重试,它也会直接在日志中显示快速失败,然后跳过其余部分,没有任何重试。

没有重试 Cypress重试全局配置不起作用。

如果您需要更多关于此的信息,我可以发送给您,但根据文档,全局配置应该足够了,而且fail-fast插件也说:

更新:重试和不同尝试在Open模式下正常工作。另外,我注意到可能是HTML报告的问题,它只在运行模式下生成。当我已经实施了HTML报告时,我是否需要配置其他内容来进行重试?

英文:

I have a problem with Retries in cypress.
I am usisng the fail-fast pluging also and this work perfect.
I have added in my cypress.config.ts configuration the retries option as global configuration as explained in the official documentation

Cypress重试全局配置不起作用。

all works fantastic, the html reports, the fail fast and so on, but not the retries, no idea why. I have review the official doc like one hundred times and also the fail fast doc just in case this is doing something with the retries but doesn't say to much.

when an error fails on run mode, even if it is configured for 2 retries it directly show in the log the fail fast and thats it, skip the rest without any retries.

Cypress重试全局配置不起作用。

Cypress重试全局配置不起作用。

NO retries at all Cypress重试全局配置不起作用。

If you need more information about it I can send it, but according to the doc with the global configuration should be enough and also the fail fast plugin says:

Cypress重试全局配置不起作用。

it doesnt says anything elase about that something must be done with retries

UPDATE: The retries and different Attempts works fine but in Open mode only. Also I have seen that maybe is a problem because of the HTML report that only is generated in run mode.
Do I have to configure something else for retries when I also have implemented the HTML report?

答案1

得分: 4

我使用这个库 cypress-fail-fast 进行了一个简单的测试,重试次数设置为 2(两种模式都是如此)。

它表现如我所期望的那样,第一个失败的测试重试了 2 次,而第二个测试由于失败快速配置的原因未按预期执行。

测试

describe('template spec', () => {

  it('fails test 1', () => {
    expect(true).to.eq(false)
  })  
  
  it('fails test 2', () => {
    expect(true).to.eq(false)
  })
})

配置

const { defineConfig } = require("cypress");

module.exports = defineConfig({
  retries: {
    runMode: 2,
    openMode: 2,
  },
  e2e: {
    setupNodeEvents(on, config) {
      require("cypress-fail-fast/plugin")(on, config);
      return config;
    },
  },
});

支持

// 使用 ES2015 语法导入 commands.js:
import './commands'
import "cypress-fail-fast";

运行模式

  正在运行:  spec.cy.js                                                                      (1 of 1)


  模板规范
    ( 1 次尝试) 通过
    ( 2 次尝试) 通过
    1) 通过
[fail-fast] 失败的测试: 1/1
[fail-fast] 启用跳过模式


  0 通过 (2s)
  1 失败

  1) 模板规范
       通过:
     断言错误: 期望值为 true实际值为 false
      at Context.eval (webpack:///./cypress/e2e/spec.cy.js:3:20)

[fail-fast] 由于先前的失败停止 Cypress 运行程序
英文:

I made a simple test with this library cypress-fail-fast + retries set to 2 (both modes).

I behaves as I would expect, the first failing test retries 2 times, and the second test does not execute as expected because of the fail-fast configuration.

test

describe('template spec', () => {

  it('fails test 1', () => {
    expect(true).to.eq(false)
  })  
  
  it('fails test 2', () => {
    expect(true).to.eq(false)
  })
})

config

const { defineConfig } = require("cypress");

module.exports = defineConfig({
  retries: {
    runMode: 2,
    openMode: 2,
  },
  e2e: {
    setupNodeEvents(on, config) {
      require("cypress-fail-fast/plugin")(on, config);
      return config;
    },
  },
});

support

// Import commands.js using ES2015 syntax:
import './commands'
import "cypress-fail-fast";

run mode

  Running:  spec.cy.js                                                                      (1 of 1)


  template spec
    (Attempt 1 of 3) passes
    (Attempt 2 of 3) passes
    1) passes
[fail-fast] Failed tests: 1/1
[fail-fast] Enabling skip mode


  0 passing (2s)
  1 failing

  1) template spec
       passes:
     AssertionError: expected true to equal false
      at Context.eval (webpack:///./cypress/e2e/spec.cy.js:3:20)

[fail-fast] Stopping Cypress runner due to a previous failure

huangapple
  • 本文由 发表于 2023年5月24日 22:48:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/76324789.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定