npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

grunt-nightwatch

v0.5.4

Published

Run your Nightwatch.js tests with Grunt

Readme

Grunt meets Nightwatch.js

Build Status NPM version

Automatize your tests:

module.exports = function(grunt) {
  grunt.initConfig({
    nightwatch: {
      options: { /* see below */ }
    }
  });

  grunt.loadNpmTasks('grunt-nightwatch');
};

Write some tests:

tests/default/google-test.js

module.exports = {
  'Demo test Google': function(browser) {
    browser
      .url('http://www.google.com')
      .waitForElementVisible('body', 1000)
      .setValue('input[type=text]', 'nodejs')
      .waitForElementVisible('button[name=btnG]', 1000)
      .click('button[name=btnG]').pause(1000)
      .assert.containsText('#ires', 'joyent/node')
      .end();
  }
};

Execute:

$ grunt nightwatch      # target: default
$ grunt nightwatch:A    # target: A
$ grunt nightwatch:A:B  # targets: A, B

Options

Currently, grunt-nightwatch supports the same options as nwrun can handle.

Note that the nighwatch.json file settings is fully supported, but your task options will override them if needed.

Gruntfile.js

module.exports = function(grunt) {
  grunt.initConfig({
    nightwatch: {
      options: {
        // task options
        standalone: true,

        // download settings
        jar_version: '2.44.0',
        jar_path: '/opt/selenium/server.jar',
        jar_url: 'http://domain.com/files/selenium-server-standalone-1.2.3.jar',

        // nightwatch settings
        globals: { foo: 'bar' },
        globals_path: 'custom_tests/globals',
        custom_commands_path: 'custom_tests/helpers',
        custom_assertions_path: 'custom_tests/asserts',
        src_folders: ['custom_tests/nightwatch'],
        output_folder: 'report',
        test_settings: {},
        selenium: {}
      },
      custom: {
        // custom target + overrides
        config_path: '/path/to/file.json',
        src_folders: ['other_tests/nightwatch']
      }
    }
  });
};

CLI options

Since 0.5.0, grunt-nightwatch will pass grunt.cli.options as the argv option to nwrun.

This means you can use grunt nightwatch:A:B --group foo --tag bar directly on the CLI.

Known issues

When running in parallel Nightwatch will copy the process.argv and it may produce bugs if you expect a single boolean argument like grunt nightwatch:A:B --standalone.

It will spawn grunt nightwatch --standalone --env A and the argv will be erroneously parsed as --standalone=--env.

Targets

All options are the same as the main settings.

nightwatch: {
  demo: { /* see above */ }
}

Now you can execute grunt nightwatch:demo to run your tests.

Note that your tests must be grouped together as follows: tests/<group>/test.js

Running tests with different browsers

nightwatch: {
      options: {
          // task options
          standalone: true,
          // download settings
          jar_version: '2.53.0',
          jar_path: '../nightwatch/selenium-server-standalone-2.53.0.jar',
          // jar_url: 'http://domain.com/files/selenium-server-standalone-1.2.3.jar',
          src_folders: ['custom_tests/nightwatch'],
          test_settings: {
              phantom: {
                  "desiredCapabilities": {
                      "browserName": "phantomjs",
                      "phantomjs.binary.path": "binaries/nightwatch/phantomjs.exe"
                  }
              },
              firefox: {
                  "desiredCapabilities": {
                      "browserName": "firefox"
                  }
              },
              chrome: {
                  "desiredCapabilities": {
                      "browserName": "chrome"
                  },
                  "cli_args" : {
                      "webdriver.chrome.driver" : "binaries/nightwatch/chromedriver.exe"
                  }
              }
          }
      }
  }

This configuration allows you to run your tests against different browsers by calling grunt nightwatch:chrome or grunt nightwatch:phantom etc.