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 🙏

© 2024 – Pkg Stats / Ryan Hefner

testarmada-magellan-nightwatch

v4.1.2

Published

Nightwatch.js adapter for Magellan

Downloads

14

Readme

magellan-nightwatch

The NightwatchJS adapter for Magellan

IMPORTANT UPDATE NOTICE

In [email protected] we've removed Chromedriver, Phantomjs and Selenium-server as these are not required while running your test on Saucelabs. However, they are still necessary if you want to run test locally. To use them, you will have to

  1. Copy/cat following code to package.json of your test repo.
"dependencies": {
  "selenium-server": "2.49.1",
  "chromedriver": "2.16.0",
  "phantomjs": "^1.9.19"
}
  1. Run npm install again. Dependencies will be installed in ${REPO_ROOT}/node_modules.
  2. Make sure your nightwatch.json file has the following change
"selenium": {
  "start_process": true,
  "server_path": "./node_modules/selenium-server/lib/runner/selenium-server-standalone-2.49.1.jar",
  "log_path": "reports",
  "host": "127.0.0.1",
  "port": 12001,
  "cli_args": {
    "webdriver.ie.driver": "",
    "webdriver.chrome.driver": "./node_modules/chromedriver/lib/chromedriver/chromedriver"
  }
}

if you're using Phantomjs

"test_settings":{
  "phantomjs": {
    "desiredCapabilities": {
      "browserName": "phantomjs",
      "javascriptEnabled": true,
      "acceptSslCerts": true,
      "phantomjs.binary.path": "./node_modules/phantomjs/bin/phantomjs"
    }
  }
}

Running Tests

For instructions on how to run tests, please see the magellan documentation at: https://github.com/TestArmada/magellan

Writing Tests

Tests are structured as simple modules with a single exported object containing keyed functions. The functions are executed in the order in which they appear in the object source. Each function represents a step in the test, and its key in the test object should represent the name of the step. Each step function gets a client as an argument which represents a browser. For more information on writing tests, see the Nightwatch.js documentation.

  var MagellanTest = require("testarmada-magellan-nightwatch/lib/base-test-class");

  module.exports = new MyTest({
    "Load homepage": function (client) {
      client
        .url("http://localhost/");
    },

    "Verify header is visible": function (client) {
      client
        .getEl("#header");
    }

    "Reveal help modal": function (client)
      client
        .clickAutomationEl("show-help")
        .getEl("#help-modal")
        .assert.elContainsText("#help-modal", "This is the help modal");
    }
  });

For more examples, see the boilerplate project at: https://github.com/TestArmada/boilerplate

Command Vocabulary

magellan-nightwatch is a wrapper around Nightwatch.js, but is constrained to a limited subset of Nightwatch vocabulary to promote reliability.

Enhanced Command List

If you're familiar with Nightwatch or are looking to translate Nightwatch examples into magellan-nightwatch, refer to the table below for equivalent enhanced (i.e. more reliable) versions of Nightwatch commands:

Custom selector tokens

All magellan-nightwatch selector paths can refer to a {token} which your application can implement a replacement value. The implementation is set as a static value on the BaseTestClass as selectorToken. For example, to replace {foo} with [data-automation-id="foo"] you would use

require('testarmada-magellan-nightwatch/lib/base-test-class').selectorToken = function (value) {
  return '[data-selector-id="' + value + '"]';
}

Custom Commands Examples

The commands included with magellan-nightwatch are safer, more reliable and "thrash-resistent" versions of Nightwatch commands. Note that clickEl(), clickAutomationEl(), and setElValue() are safe to call without first waiting for their selector to appear because they execute getEl() as part of their internals. Consider the following snippet:

  client
    .getEl("#submit_order")
    .clickEl("#submit_order")

The above snippet can be shortened to the following form (and will execute faster):

  client
    .clickEl("#submit_order")

Our custom commands try be as readable and flexible as possible. For example, rather than just accepting text inside the `el(Not?)ContainsText commands, you can also include a regular expression to match text in a much more flexible way

  client
    .elContainsText("#submit_order", "Price \d+\.\d\d")

This would match "Price" followed by one more more digits, a decimal, then two more digits. You can use regexper to help visualize and debug regular expressions

As-is Supported Nightwatch Vocabulary

All Nightwatch commands and assertions are supported out of the box.

Supported Nightwatch Commands

Supported Nightwatch Assertions

Supported Node Assertions

  • fail
  • equal
  • notEqual
  • deepEqual
  • notDeepEqual
  • strictEqual
  • notStrictEqual
  • throws
  • doesNotThrow
  • ifError

Custom Commands

magellan-nightwatch supports the development of custom commands to allow the re-use of common parts of tests. If you're using the same snippets of code to fill out a form that appears in many tests, or have a common way to sign into your application, etc, then custom commands are for you. Please see the Nightwatch.js documentation for more on commands.

Migrating Nightwatch Configuration

To migrate an existing vanilla nightwatch.json configuration to magellan-nightwatch, update the following

Add Magellan's custom commands to your custom_commands_path:

  "custom_commands_path": [
    "./node_modules/testarmada-magellan-nightwatch/lib/commands",

Add Magellan's custom assertions to your custom_assertions_path:

  "custom_assertions_path": [
    "./node_modules/testarmada-magellan-nightwatch/lib/assertions",

Ensure Selenium server/driver paths are correct:

  "selenium": {
    "start_process": true,
    "server_path": "./node_modules/testarmada-magellan-nightwatch/node_modules/selenium-server/lib/runner/selenium-server-standalone-2.49.0.jar",
    "log_path": "reports",
    "host": "127.0.0.1",
    "port": 4444,
    "cli_args": {
      "webdriver.chrome.driver": "./node_modules/testarmada-magellan-nightwatch/node_modules/chromedriver/lib/chromedriver/chromedriver",
      "webdriver.ie.driver": ""
    }
  },

Note: pay special attention to the version number for the selenium server above, currently at version 2.49.0*

Set up phantomjs path:

  "phantomjs" : {
    "desiredCapabilities" : {
      "browserName" : "phantomjs",
      "javascriptEnabled" : true,
      "acceptSslCerts" : true,
      "phantomjs.binary.path" : "./node_modules/testarmada-magellan-nightwatch/node_modules/phantomjs/bin/phantomjs"

=======

Version History

1.4.19

Released 25 July 2015

  • Full refactor

1.4.20

Released 28 July 2015

  • Added setMaskedElValue()
  • Updated README with nightwatch.json migration instructions, better base test example.
  • Updated selenium-server to 2.46.0 (see migration guide on how this affects nightwatch.json)

1.4.23

Released 06 August 2015

  • Use default node-chromedriver install instead of fork (previously needed to work around firewall issue)

1.5.1

Released 27 August 2015

1.5.2

1.5.3

  • Added getPerformance() command to retrieve the performance results for a url

  • Fixed problem with jQuery injection in some assertions.

1.5.5

Released 1 October 2015

  • Added getElValue()
  • Added getEls()
  • Added scrollToEl()

4.0.0

  • Updated selenium-standalone to 2.49.0