我不知道为什么(或者如果不允许) testcafe不会运行我的runner类文件。当前设置
package.json:
{
...
"test:integration": "testcafe ./bin/integration.js",
...
"devDependencies": {
...
"testcafe": "^1.5.0",
"testcafe-react-selectors": "^3.2.0",
...
}
bin/integration.js (package.json级别的bin)
const createTestCafe = require('testcafe')
let runner = null
let testcafe = null
createTestCafe('localhost', 1337, 1338)
.then(tc => {
testcafe = tc
runner = testcafe.createRunner()
return testcafe.createBrowserConnection()
})
.then(remoteConnection => {
// Outputs remoteConnection.url so that it can be visited from the remote browser.
console.log('remote url:', remoteConnection.url)
remoteConnection.once('ready', () => {
runner
.src('../integration-tests/*test.js*')
.browsers(['chrome'])
.run({
selectorTimeout: 50000,
assertionTimeout: 7000,
pageLoadTimeout: 8000
})
.then(failed => {
console.log('failed tests:', failed)
testcafe.close()
})
.catch(error => {
console.log(error)
})
})
})
收到错误:ERROR Unable to find the browser. "./bin/integration.js" is not a browser alias or path to an executable file.
我做错了什么?
提前感谢
发布于 2019-10-14 10:10:41
据我所知,您希望使用testcafe来运行测试。在这种情况下,您不需要使用testcafe
命令启动测试。
testcafe
命令通常至少需要两个参数:browsers
和sources
。当您使用testcafe ./bin/integration.js
命令时,CLI参数解析器将参数作为浏览器别名处理,因此您会看到错误。
我假设您需要使用以下命令运行脚本:node ./bin/integration.js
https://stackoverflow.com/questions/58368383
复制