【问题标题】:Cannot read source folder attempting to make any action无法读取尝试执行任何操作的源文件夹
【发布时间】:2017-10-09 23:06:39
【问题描述】:

当我尝试使用 npm run project_one 运行我的守夜项目时,我收到了此响应。

There was an error while starting the test runner:

Error: Cannot read source folder: /Users/BenyJo/examples/tests
    at /Users/BenyJo/node_modules/nightwatch/lib/runner/run.js:203:21
    at /Users/BenyJo/node_modules/nightwatch/lib/runner/walk.js:97:18
    at FSReqWrap.oncomplete (fs.js:153:21)

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! package@1.0.0 project_one: `nightwatch`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the package@1.0.0 project_one script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

每当我使用 npm 使用任何 nightwatch 命令时,我都会收到相同的错误,我的 Nightwatch 配置如下:

{
  "src_folders" : ["tests"],
  "output_folder" : "reports",

  "selenium" : {
    "start_process" : true,
    "server_path" : "./bin/selenium_v360.jar",
    "log_path" : "",
    "port" : 4444,
    "cli_args" : {
      "webdriver.chrome.driver" : "./bin/chromedriver"
    }
  },

  "test_settings" : {
    "default" : {
      "launch_url" : "http://localhost",
      "selenium_port"  : 4444,
      "selenium_host"  : "localhost",
      "desiredCapabilities": {
        "browserName": "chrome",
        "javascriptEnabled": true,
        "acceptSslCerts": true
      }
    }
  }
}

我注意到在那个错误中,没有调用文件,那里应该有一个 nightwatch 文件夹。 /Users/BenyJo/examples/tests

【问题讨论】:

标签: javascript node.js testing automated-tests nightwatch.js


【解决方案1】:

['nightwatch', '--', '--group', "$testSuite", '--env', "$projectEnv"].

我已解决问题“错误:无法读取源文件夹:/”

以这两种方式执行命令:

nightwatch -- --group testSuite --env nameEnv
npm run test -- --group testSuite --env nameEnv


nightwatch -- --test testsFile/testSuite --env default

npm run test -- --test testsFile/testSuite --env default

记住双参数行:“-- --group”。

它以这种方式将 runner.js 解析为 Nightwatch 执行

您可以替换项目中的组或文件测试并查看nighwatch.json中的测试设置以解析参数--env-e

【讨论】:

    【解决方案2】:

    遇到同样的问题,我的配置文件名有错字。它必须命名为“nightwatch.json”(我的命名为“nightwatch.js”)。

    【讨论】:

      猜你喜欢
      • 2014-06-27
      • 1970-01-01
      • 1970-01-01
      • 2021-07-27
      • 2021-01-25
      • 2023-03-24
      • 2018-11-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多