NightwatchJS - 没有用于报告XML文件的此类文件或目录

时间:2014-03-03 08:43:55

标签: javascript node.js selenium automated-tests

成功运行测试后,我不断收到报告XML文件的错误no such file or directory。它似乎在查找错误的目录:

no such file or directory 'E:\source\test\nightwatch\reports\E:\source\test\nightwatch\tests\file1.xml'

我玩settings.json,但无济于事。有任何想法如何让它成功创建报告?

NightwatchJS版本: 0.2.7

文件夹结构

/source
- /test
  - /nightwatch
    - nightwatch.js
    - settings.json
    - /reports
    - /screenshots
    - /tests
      - file1.js
      - file2.js
      - file3.js
- /node_modules
  - /nightwatch
    - [nightwatch files]
- app.server.js
- [other files for my app]

nightwatch.js

require('nightwatch/bin/runner.js');

settings.json

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

  "selenium" : {
    "start_process" : true,
    "server_path" : "C:/Program Files/Selenium/selenium-server-standalone-2.39.0.jar",
    "log_path" : "reports",
    "host" : "127.0.0.1",
    "port" : 4444  
  },

  "test_settings" : {
    "default" : {
      "launch_url" : "http://localhost",
      "port"  : 4444,
      "silent": true,
      "firefox_profile": false,
      "screenshots" : {
        "enabled" : true,
        "path" : "screenshots"
      },
      "desiredCapabilities": {
        "browserName": "chrome",
        "javascriptEnabled": true,
        "acceptSslCerts": true
      }
    }
  }
}

示例输出

E:\source\test\nightwatch>node nightwatch.js -t tests/file1.js
Starting selenium server... started - PID:  7472
Running tests

[ E:\source\test\nightwatch\tests\file1 module ]

Running:  Test File1
✔  [some assertions here...]
OK. 6 assertions passed.

fs.js:427
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^
Error: ENOENT, no such file or directory 'E:\source\test\nightwatch\reports\E:\source\test\nightwatch\tests\file1.xml'
    at Object.fs.openSync (fs.js:427:18)
    at Object.fs.writeFileSync (fs.js:966:15)
    at E:\source\node_modules\nightwatch\runner\reporters\junit.js:36:10
    at fs.js:266:14
    at Object.oncomplete (fs.js:107:15)

2 个答案:

答案 0 :(得分:0)

您正在运行过时的nightwatch版本,该版本在Windows上保存报告文件时存在错误。最新版本为0.3.7。 要更新到最新版本,您可以运行:

npm update nightwatch

答案 1 :(得分:0)

您可以尝试更新src的设置并输出到相对于跑步者:

"src_folders": ["./tests"],
"output_folder": "./reports",