【问题标题】:Unable to call a function from Fixture.before Method无法从 Fixture.before 方法调用函数
【发布时间】:2020-05-14 07:45:44
【问题描述】:

我正在尝试实现一个具有多个测试的夹具,所有测试都相互依赖 因此我想清理数据库并从 Fixture.before 方法只执行一次登录 所以它看起来像这样:

fixture `testProject`.page(baseUrl)
    .before(async t => {
    await loginPM.login()
    await base.clearDB()
})
.beforeEach(async t => {
// some steps before each test
})
test 1
test 2 
test 3

此场景引发以下异常:


fixture.before 钩子中的错误 - 无法在应执行测试控制器操作的上下文中隐式解析测试运行。改用测试函数的 't' 参数


关于为什么 testcafe 不支持从 Fixture.before 方法调用函数的任何想法

【问题讨论】:

    标签: testing automation automated-tests e2e-testing testcafe


    【解决方案1】:

    fixture.before 钩子在测试之间运行,并且无权访问测试页面。有关其使用的详细信息,请参阅以下帮助主题:Fixture.before Method。如果您需要在开始所有测试之前对每个夹具执行一次测试操作(单击、键入文本等),请参阅此模块:testcafe-once-hook 模块。以下是如何使用它的示例:https://github.com/AlexKamaev/testcafe-once-hook-example

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-21
      • 2015-05-04
      相关资源
      最近更新 更多