cypress - 推荐如何在 Cypress 中使用断言
问题描述
您如何在项目中使用 Cypress 中的断言?在同一步骤 (it()) 或不同 (it()) 中执行步骤和断言?
1:
describe('test', ()=> {
it('clicks on button "Add new user"', ()=> {
// click action
// assert (should()) modal to add new user is opened
})
})
或者
2:
describe('test', ()=> {
it('clicks on button "Add new user"', ()=> {
// click action
})
it('Expect: modal should be opened', ()=> {
// assert (should()) modal to add new user is opened
})
})
在量角器中,我使用过没有。1,在同一个 it() 中使用 action 方法和 expect 方法,但是在 Cypress 中,您不能为 should() 断言添加自定义消息,以准确查看失败的原因。(例如'模态应该打开')
谢谢!
解决方案
推荐阅读
- search - 如何在 Oracle 中搜索逗号分隔的 DB 列
- javascript - 如何在画布中定位 Path2D SVG 元素?
- ruby-on-rails - 如何在选择框中显示现有数据
- vb.net - 从 DatagridView 创建 Tiff 位图文件
- graphql - AppSync 中的 GraphQL 字段级验证
- c# - 无法在选择列表中保存多个选择 - asp.net core web app razor pages
- c# - C# 8 在返回具有可空约束的可空泛型时发出警告
- ios - 尝试使用 babel-plugin-proposal-class-properties 时使用 .babelrc 的语法加倍
- mysql - 如何优化我的 Google Cloud SQL (MySQL) 数据库以与 API 一起使用
- php - 打印调试堆栈跟踪(在块内)