nightwatch.js - Nightwatch 测试库中的 getByRole 在基本示例中引发错误
问题描述
使用Nightwatch.js + 测试库运行基本示例时,我不断收到错误消息:
[Ecosia Search With TL] Test Suite
==================================
ℹ Connected to localhost on port 9515 (1077ms).
Using: chrome (87.0.4280.66) on Mac OS X platform.
Running: Demo test ecosia.org
matcher.test is not a function
FAILED: 1 errors (935ms)
_________________________________________________
TEST FAILURE: 1 error during execution; 0 tests failed, 0 passed (2.779s)
✖ ecosiaSearchWithTL
– Demo test ecosia.org (935ms)
Error: [object Object]
at processTicksAndRejections (internal/process/task_queues.js:97:5)
npm ERR! Test failed. See above for more details.
这是我唯一的测试:
const { getQueriesFrom } = require('@testing-library/nightwatch')
module.exports = {
async beforeEach(browser) {
await browser.url('https://www.ecosia.org/')
},
async 'Demo test ecosia.org'(browser) {
const { getByRole } = getQueriesFrom(browser)
const searchBox = await getByRole('searchbox', { name: /search form/i })
browser.setValue(searchBox, 'nightwatch')
const submit = await getByRole('button', { name: /submit/i })
browser.click(submit)
browser.end()
}
}
我的nightwatch.conf.js
:
module.exports = {
src_folders: ['tests'],
webdriver: {
start_process: true,
port: 9515,
server_path: "node_modules/.bin/chromedriver",
},
test_settings: {
default: {
desiredCapabilities : {
browserName: "chrome"
}
}
}
};
知道为什么我不断收到该错误吗?它可以在没有测试库的情况下完美运行。
解决方案
推荐阅读
- c# - 将 varchar 值“Batsman”转换为数据类型 int 时转换失败
- c++ - 使用类模板范围内的枚举而不指定模板参数
- javascript - 在 for 循环中超时获取
- python - Python 中基于梯度的优化
- sql - Postgresql 使用 ILIKE 搜索非 ascii 字符
- geojson - GDALException OGR 失败
- c# - 是否可以在 EF Core Include 查询中加入不相关的表
- python - pandas 风格高亮格式的分步说明是什么?
- xcode - 我可以用一些模板自动填充 Xcode 的提交消息吗?
- java - 为什么将微服务分布式事务的模式命名为 SAGA?