use*_*016 6 mocha.js picocontainer cypress
我正在开发一个 Web 测试自动化框架,并且希望通过另一个describe()cypress ..spec.js文件中存在的方法,在一个 cypress ..spec.js 文件中的块中提供一些功能?
请阅读Mocha 中提供的
共享行为工具: https://github.com/mochajs/mocha/wiki/Shared-Behaviours

我尝试过,但它不起作用。1.是否可以实现类似于Mocha Shared步骤的东西(如上所述)?2.或者有类似Cucumber-ruby/Pico-container的WORLD对象的东西吗?
好心提醒。
您可以使用自定义命令在多个文件上重复使用步骤。这可以通过以下步骤来完成。
cypress/support/commands.js使用要在多个文件中使用的步骤创建自定义命令。您可以使用以下语法:Cypress.Commands.add('customCommand', function() {
cy.get('object')
.clear()
.type('something')
// do other steps
})
Run Code Online (Sandbox Code Playgroud)
describe('Description of the test', function () {
it('first scenario of the test', function () {
cy.customCommand()
})
})
Run Code Online (Sandbox Code Playgroud)
结论:要在多个测试文件中共享步骤,您需要将共享步骤放在commands.js 中而不是放在测试文件中。
| 归档时间: |
|
| 查看次数: |
1033 次 |
| 最近记录: |