无法读取尝试进行任何操作的源文件夹

时间:2017-10-09 23:06:39

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

尝试使用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
      }
    }
  }
}

screenshot

我注意到在那个错误中,没有调用文件,那里应该有一个nightwatch文件夹。 /用户/ BenyJo /示例/测试

2 个答案:

答案 0 :(得分:2)

SELECT dbo.fnc_getHobbies(hobbyids) FROM hobbies

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

以这两种方式执行命令:

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

请记住双参数行:" - --group"。

以这种方式解决了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 Nightwatch执行

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

答案 1 :(得分:1)

出现同样的问题,我的配置文件名中有一个拼写错误。它必须命名为" nightwatch.json" (我的名字叫#34; nightwatch.js")。