Overview

TeamCity formatter for Nightwatch.js end-to-end testing framework. Its output can be used by other tools to visualize the report.

Example with Configuration

Step 0: Install Nightwatch

Follow the guide or watch the video to install Nightwatch from scratch.

Step 1: Installing Nightwatch Teamcity Reporter

Install nightwatch-teamcity as a dependency in your nightwatch project.

npm i nightwatch-teamcity --save-dev

Step 2: Run an example test

Consider the duckDuckGo.js example test :

describe('duckduckgo example', function() {
  it('Search Nightwatch.js and check results', function(browser) {
    browser
      .navigateTo('https://duckduckgo.com')
      .waitForElementVisible('#search_form_input_homepage')
      .sendKeys('#search_form_input_homepage', ['Nightwatch.js'])
      .click('#search_button_homepage')
      .assert.visible('.results--main')
      .assert.textContains('.results--main', 'Nightwatch.js');
  }); 
});

You can run this test using the command:

npx nightwatch examples/tests/duckDuckGo.js -–reporter node_modules/nightwatch-teamcity/index.js

You can also define your reporter in a separate file (eg. nightwatch-reporter.js) by including the following code, and then specify the path to the file using the --reporter cli argument.

const teamCityFormatter = require("nightwatch-teamcity").format;

module.exports = { reporter: (results,done)=>{ teamCityFormatter(results); done(); } };
npx nightwatch examples/tests/duckDuckGo.js --reporter ./nightwatch-reporter.js

Step 3: View the JSON report

The TeamCity report can be seen in console and It will look something like this:

Composing with other reportes

In order to compose with another reporter (e.g. nightwatch-html-reporter), you can follow the example shown below:

nightwatch-reporter.js
const HtmlReporter = require("nightwatch-html-reporter");

const teamCityFormatter = require("nightwatch-teamcity").format;
const reporter = new HtmlReporter({ reportsDirectory: "./reports", });
module.exports = { write: function(results, options, done) { teamCityFormatter(results); reporter.fn(results, done); done(); } };

Recommended content