Jplus2
Jplus2

Reputation: 2531

Write test output to file in NightwatchJS

I want to write the actual test output of NightwatchJS tests (not the browser console) to a file. I can't seem to find any resource regarding about this.

The log_path option is ok, it does log some stuff on the location you specified after the test, but its not the same data vs the actual test output.

below is my nightwatch.json file

{
  "src_folders" : [ 
  "tests" , 
  "tests/settings/general" 
],

"page_objects_path" : [ 
  "page_objects/backend" , 
  "page_objects/frontend" ,
  "page_objects/backend/settings/general"
],

"globals_path" : "./nightwatch.globals.js",

"webdriver" : {
  "start_process" : true,
  "log_path"      : "./logs"
},

"test_settings" : {

  "default" : {
    "webdriver": {
      "server_path" : "node_modules/.bin/chromedriver",
      "port"        : 9515,
      "cli_args"    : [ "--log" , "debug" ]
    },
    "desiredCapabilities": {
      "browserName"         : "chrome",
      "acceptInsecureCerts" : true,
      "javascriptEnabled"   : true,
      "acceptSslCerts"      : true
    }
  },

  "firefox" : {
    "webdriver": {
      "server_path" : "node_modules/.bin/geckodriver",
      "port"        : 4444,
      "cli_args"    : [ "--log" , "debug" ]
    },
    "desiredCapabilities": {
      "browserName"         : "firefox",
      "acceptInsecureCerts" : true,
      "javascriptEnabled"   : true,
      "acceptSslCerts"      : true
    }
  }

}

}

Hope you can help me on this. Thanks in advance.

Upvotes: 0

Views: 1477

Answers (2)

FloydCorbin
FloydCorbin

Reputation: 11

You could add '> tests_output/Test_filename.txt' after the command to run the test. So, I have my package.json file set up with the script 'test' for running Nightwatch. My terminal input to save the output as a file would look like this:

npm test > /tests_output/testRun100720.txt

This will place the output file I name testRun100720.txt into the tests_output folder.

Upvotes: 1

Asoc
Asoc

Reputation: 51

Can you provide a little more detail of what you mean by 'output'?

In the meantime, try adding "output_folder": "reports/", to your json file, this should generate XML output from the Nightwatch logger which may provide more details.

Upvotes: 0

Related Questions