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

nightwatch-js-remote-assert

v1.0.0

Published

A nightwatch plugin for remote assertions

Readme

nightwatch-js-remote-assert

A library which adds remote assertions, fixtures, and test data to Nightwatch

What?

This library is intended to work with a backend such as JUnit HTTP. Check out that project for the rationale and how to set up the server component.

How?

  • Clone the JUnit HTTP repository and run the example application and test servers
  • Clone this repo
  • Run npm install
  • Download Chromedriver for your platfrom
  • Download and run the standalone Selenium client according to the instructions on the Nightwatch site

Note: You'll need to put Chromedriver and the Selenium standalone server jar in the same directory; that's what the nightwatch config expects.

  • Run node example.js
  • Run nightwatch
  • Check out the test output in the terminal

Example

The example Express application (/example.js) serves up a simple front end for the example API in the JUnit HTTP project. The test included in tests/example.js exercises that application and shows how to use the included "assert.remote", "loadTestData", and "remoteFixture" functions work. For more information about how these work and why you want to use them, see the documentation for the backend at JUnit HTTP.

const URL = 'http://localhost:8082'
const NAME_INPUT = 'input[id=note-name]'
const CONTENT_INPUT = 'textarea[id=note-content]'
const SAVE_BUTTON = 'button[id=save-button]'
const LOAD_BUTTON = 'button[id=load-button]'
const STATUS_ELEMENT = '#status'
const REMOTE_TEST_GROUP = 'io.dfox.junit.http.example.ExampleTest'
const TEST_DATA = 'notes.json'

module.exports = {
  'Notes can be saved' : browser => {
    browser.loadTestData(TEST_DATA, notes => {
      browser
        .url(URL)
        .waitForElementVisible('body', 1000)
        .setValue(NAME_INPUT, notes.save.name)
        .setValue(CONTENT_INPUT, notes.save.contents)
        .click(SAVE_BUTTON)
        .pause(1000)
        .assert.containsText(STATUS_ELEMENT, 'Saved note: ' + notes.save.name)
        .assert.remote(REMOTE_TEST_GROUP, 'noteSaved')
        .end();
    });
  },

  'Notes can be loaded' : browser => {
    browser.loadTestData(TEST_DATA, notes => {
      browser
        .url(URL)
        .waitForElementVisible('body', 1000)
        .setValue(NAME_INPUT, notes.load.name)
        .click(LOAD_BUTTON)
        .pause(1000)
        .assert.containsText(STATUS_ELEMENT, 'Loaded note: ' + notes.load.name)
        .assert.valueContains(CONTENT_INPUT, notes.load.contents)
        .end();
    });
  },

  'Notes can be loaded using fixture' : browser => {
    browser.loadTestData(TEST_DATA, notes => {
      browser
        .url(URL)
        .waitForElementVisible('body', 1000)
        .setValue(NAME_INPUT, notes.fixture.name)
        .click(LOAD_BUTTON)
        .pause(1000)
        .assert.containsText(STATUS_ELEMENT, 'Error loading note: Not Found')
        .assert.valueContains(CONTENT_INPUT, '')
        .remoteFixture(REMOTE_TEST_GROUP, 'createNote', () => {
          browser
            .click(LOAD_BUTTON)
            .pause(1000)
            .assert.containsText(STATUS_ELEMENT, 'Loaded note: ' + notes.fixture.name)
            .assert.valueContains(CONTENT_INPUT, notes.fixture.contents)
            .end();
        });
    });
  }
};

How does the assertion know where the test server is? You need to add the following block to the "globals" section of the configuration, which can be changed per environment:

"test_settings" : {
  "default" : {
    "globals":{
      "remoteTest":{
        "server":{
          "host": "localhost",
          "port": 8081
        }
      }
    }
  }
}