【问题标题】:Cypress beforeEach setup with cy.requestCypress beforeEach 使用 cy.request 设置
【发布时间】:2021-07-30 09:42:05
【问题描述】:

我的测试需要在数据库中创建一些项目,所以在每次测试之前,我都会向 API 发出一些请求以使用 cy.request() 创建它们

这是一种好的做法还是我应该以其他方式准备设置?

beforeEach(() => {
  cy.request(someUrl)
  cy.request(anotherUrl)
})

it('test smth', () => {
  // do some stuff
})

it('test something', () => {
  // do some stuff
})

【问题讨论】:

    标签: automated-tests cypress


    【解决方案1】:

    是的,这是一个很好的做法。阅读更多here。此外,您还可以观看 Brian Mann here 的精彩演讲。

    请记住,测试应该始终能够相互独立地运行并且仍然可以通过。阅读更多here

    【讨论】:

      猜你喜欢
      • 2023-03-07
      • 2022-10-17
      • 1970-01-01
      • 1970-01-01
      • 2021-07-08
      • 1970-01-01
      • 2023-01-11
      • 2021-01-29
      • 2021-07-18
      相关资源
      最近更新 更多