首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何将testCafe指向可执行的启动文件

如何将testCafe指向可执行的启动文件
EN

Stack Overflow用户
提问于 2019-10-13 22:50:12
回答 1查看 283关注 0票数 2

我不知道为什么(或者如果不允许) testcafe不会运行我的runner类文件。当前设置

package.json:

代码语言:javascript
运行
AI代码解释
复制
{
...
 "test:integration": "testcafe ./bin/integration.js",
...
  "devDependencies": {
    ...
    "testcafe": "^1.5.0",
    "testcafe-react-selectors": "^3.2.0",
    ...
}

bin/integration.js (package.json级别的bin)

代码语言:javascript
运行
AI代码解释
复制
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.

我做错了什么?

提前感谢

EN

回答 1

Stack Overflow用户

发布于 2019-10-14 10:10:41

据我所知,您希望使用testcafe来运行测试。在这种情况下,您不需要使用testcafe命令启动测试。

testcafe命令通常至少需要两个参数:browserssources。当您使用testcafe ./bin/integration.js命令时,CLI参数解析器将参数作为浏览器别名处理,因此您会看到错误。

我假设您需要使用以下命令运行脚本:node ./bin/integration.js

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58368383

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档