【问题标题】:Invalid first argument. It must be a callback function第一个参数无效。必须是回调函数
【发布时间】:2020-03-08 19:58:45
【问题描述】:

我是硒自动化测试的新手。我正在尝试添加一个 beforeAll() 和 afterAll() 函数来打开和关闭浏览器一次并跨多个文件运行所有测试,而不是在所有文件中单独调用它并打开多个浏览器并每次加载网站。

这是我的测试: 在此处输入图片说明

Output

This is beforeAll() and afterAll() methods sitting in a separate file

Actual Test

【问题讨论】:

  • 在所有单个文件中添加 beforeAll() 和 afterAll() 时,此测试有效。
  • 重新编辑您的问题。不要粘贴代码的屏幕截图。用代码标记突出显示它。

标签: selenium jestjs


【解决方案1】:

beforeAll 不同于 itdescribe。如果您使用回调,第一个参数只能为空或done

// works
beforeEach((done) => {
 ...
 done()
});

// works
beforeEach(() => {
 return asyncSomething()
});

// Doesn't work. 
beforeEach(("Don't add string here") => {..});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-05-08
    • 2020-08-31
    • 2017-06-27
    • 1970-01-01
    • 2017-04-04
    • 1970-01-01
    • 2018-08-29
    • 1970-01-01
    相关资源
    最近更新 更多