Report file isn't created when using Mocha with Nightwatch

518 views
Skip to first unread message

Beni Keyserman

unread,
Jul 31, 2017, 8:41:11 AM7/31/17
to NightwatchJs
Hi,

I'm using Nightwatch with Mocha and I need to generate a report file (preferably an HTML file).
I have tried using both nightwatch-html-reporter (https://github.com/jls/nightwatch-html-reporter),

In both cases I couldn't generate the report file. The reporter works. But the file isn't generated.
Is there any other way I can generate a report file? Maybe a builtin option I missed or another library?

I'm adding my nightwatch.conf.js with the mocha reporter:

const seleniumServer = require('selenium-server-standalone-jar');
const chromeDriver = require('chromedriver');

module.exports = {
  src_folders: ['src/spec/e2e/tests'],
  page_objects_path: [
    'src/spec/e2e/pageObjects',
    'src/spec/e2e/pageObjects/common',
    'src/spec/e2e/pageObjects/checklists',
    'src/spec/e2e/pageObjects/templates',
    'src/spec/e2e/pageObjects/templates/checklistCreation',
    'src/spec/e2e/pageObjects/templates/templateCreation',
    'src/spec/e2e/pageObjects/templates/templateEdit',
    'src/spec/e2e/pageObjects/issues',
    'src/spec/e2e/pageObjects/issues/issuesCreation'
  ],
  globals_path: 'src/spec/e2e/globals/globalsModule.js',
  custom_commands_path: 'src/spec/e2e/customCommands',

  selenium: {
    start_process: true,
    server_path: seleniumServer.path,
    host: '127.0.0.1',
    port: 4444,
    cli_args: {
      'webdriver.chrome.driver': chromeDriver.path
    }
  },

  test_runner: {
    type: 'mocha',
    options: {
      ui: 'bdd',
      reporter: 'good-mocha-html-reporter',
      timeout: 15000,
      bail: false,
      savePath: './', // the path to desired location
      filename: 'report.html', // filename gets attached at the end of savePath
      mode: 'Verbose'
    }
  },

  test_settings: {
    default: {
      launch_url: 'APP URL',
      silent: true,
      desiredCapabilities: {
        browserName: 'chrome',
        javascriptEnabled: true,
        acceptSslCerts: true,
        chromeOptions: {
          args: [
            "--no-sandbox",
            "start-fullscreen"
          ]
        }
      }
    }
  }
};


Thanks!

Walter

unread,
Aug 5, 2017, 9:37:54 AM8/5/17
to NightwatchJs
Hey Beni,

I'm going to warn you that i'm no nightwatch expert. It doesn't look like you have your  "output_folder": "./reports" defined. I would recommend putting it in your nightwatch.conf.js file near your globals path. 

I'm also curious why you have each one of your page object files defined in your config file and why you didn't just do one going to your page object directory "page_objects_path" : "src/spec/e2e/pageObjects"? I also believe it is recommended that you store your page objects outside of your e2e folder as e2e implies that it stores e2e tests. In my configuration I have my page objects stored within a 'pages' folder and my e2e tests stored within tests/e2e/. 



module.exports = {
"src_folders": [
"test/e2e"// Where you are storing your Nightwatch e2e tests
],
"custom_commands_path" : "",
"custom_assertions_path" : "",
"page_objects_path" : "pages",
"globals_path" : "globals.js",
"globals" : "",
"output_folder": "./reports", // reports (test outcome) output by nightwatch
"selenium": { // downloaded by selenium-download module (see readme)
"start_process": true, // tells nightwatch to start/stop the selenium process
"server_path": "./lib/selenium-server-standalone-3.4.0.jar",
"host": "127.0.0.1",
"port": 4444, // standard selenium port
"cli_args": { // chromedriver is downloaded by selenium-download (see readme)
"webdriver.chrome.driver" : "./lib/chromedriver.exe",
"webdriver.gecko.driver" : "./lib/geckodriver.exe",
"webdriver.safari.driver" : "",
"webdriver.ie.driver" : "./lib/IEDriverServer.exe",
"webdriver.edge.driver" : "./lib/MicrosoftWebDriver.exe"
}
},

 
 
 

 
 
Reply all
Reply to author
Forward
0 new messages