TestCafe:测试不会通过无头模式
TestCafe: Tests don't pass with headless mode
我正在构建一个 React 应用程序并使用 TestCafe 编写我的功能测试。这是我的测试脚本:
"functional-tests": "testcafe chrome src/functional-tests/ --app 'yarn start'",
这些测试通过。但是如果我尝试在无头模式下 运行 它们:
"functional-tests": "testcafe 'chrome:headless' src/functional-tests/ --app 'yarn start'",
它们因以下错误而失败。
1) Cannot obtain information about the node because the specified
selector does not match any node in the DOM tree.
如果我 运行 yarn start
在单独的终端中手动(不使用 --app
标志)无头测试通过。
如何使用 --app
标志让无头测试通过?我需要 运行 在 CI/CD 脚本中进行功能测试,这就是为什么我需要一个命令来启动服务器和 运行 测试。
我通过添加 a delay to launch the app.
使其正常工作
"functional-tests": "testcafe 'chrome:headless' src/functional-tests/ --app 'yarn start' --app-init-delay 4000",
我正在构建一个 React 应用程序并使用 TestCafe 编写我的功能测试。这是我的测试脚本:
"functional-tests": "testcafe chrome src/functional-tests/ --app 'yarn start'",
这些测试通过。但是如果我尝试在无头模式下 运行 它们:
"functional-tests": "testcafe 'chrome:headless' src/functional-tests/ --app 'yarn start'",
它们因以下错误而失败。
1) Cannot obtain information about the node because the specified
selector does not match any node in the DOM tree.
如果我 运行 yarn start
在单独的终端中手动(不使用 --app
标志)无头测试通过。
如何使用 --app
标志让无头测试通过?我需要 运行 在 CI/CD 脚本中进行功能测试,这就是为什么我需要一个命令来启动服务器和 运行 测试。
我通过添加 a delay to launch the app.
使其正常工作"functional-tests": "testcafe 'chrome:headless' src/functional-tests/ --app 'yarn start' --app-init-delay 4000",