无法通过 npm 链接运行本地版本的 testcafe

Rob*_*b C 3 testing automation automated-tests e2e-testing testcafe

每当我尝试运行本地安装的 testcafe 版本时,我都会收到错误Cannot find module '../testcafe/lib/cli'. 我采取的步骤:

  1. git clone <testcafe>,然后 cd 到 testcafe
  2. npm install
  3. npm link
  4. cd 到我的自动化测试所在的仓库
  5. npm link testcafe
  6. testcafe <browser>

结果是

internal/modules/cjs/loader.js:796
    throw err;
    ^

Error: Cannot find module '/Users/rcooper/testcafe/lib/cli'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:793:17)
    at Function.Module._load (internal/modules/cjs/loader.js:686:27)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10)
    at internal/main/run_main_module.js:17:11 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}
Run Code Online (Sandbox Code Playgroud)

我还需要做些什么来运行这个库的本地版本吗?

Dmi*_*hev 5

您需要构建 TestCafe 包。npx gulp buildnpm link命令之前运行。

  • 是的,您可以对 testcafe-hammerhead 使用相同的“build”gulp 任务。 (2认同)