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

nightwatchjs-basic

v1.3.0

Published

helps to get started with nightwatchjs setup and test run on web browsers.

Downloads

6

Readme

What is Nightwatch

build npm-version npm-nightwatch

author-linkedin

Nightwatch.js is an automated testing framework for web applications and websites, written in Node.js and using the W3C WebDriver API (formerly Selenium WebDriver).

It is a complete End-to-End testing solution which aims to simplify writing automated tests and setting up Continuous Integration. Nightwatch can also be used for writing Node.js unit and integration tests.

The name Nightwatch was inspired by the famous painting The Night Watch by Dutch artist Rembrandt van Rijn. The masterpiece is prominently displayed in the Rijksmuseum, in Amsterdam - The Netherlands.

Overview of WebDriver

WebDriver is a general purpose library for automating web browsers. It was started as part of the Selenium project, which is a popular and comprehensive set of tools for browser automation initially written for Java but now with support for most programming languages.

Nightwatch uses the WebDriver API to perform the browser automation related tasks, like opening windows and clicking links for instance.

WebDriver is now a W3C specification aiming to standardize browser automation. WebDriver is a remote control interface that enables introspection and control of user agents. It provides a platform and a restful HTTP api as a way for web browsers to be remotely controlled.

Theory of Operation

Nightwatch works by communicating over a restful HTTP API with a WebDriver server (such as ChromeDriver or Selenium Server). The protocol is defined by the W3C WebDriver spec, which is derived from JSON Wire protocol. See below for an example workflow for browser initialization.

alt text

Most of the times, Nightwatch needs to send at least 2 requests to the WebDriver server in order to perform a command or assertion. ...The first one being the request to locate an element given a CSS selector (or Xpath expression) ...Next to perform the actual command/assertion on the given element.

Setup

  1. Node.js should be installed.
  2. NPM should be installed.
  3. Create a directory with nightwatchjs-basic name.
  4. Run npm init and complete with basic details.
  5. Run npm install nightwatch to install nightwatch within workspace.
  6. Download selenium and chrome drivers and copy to bin directory.
  7. Create nightwatch.json file within working directory. The nightwatch test runner binary expects a configuration file.
  8. Create tests directory and create homepage.js file.
  9. Update package.json with test runner for scripts value.

Screenshots

nightwatch.conf.js

alt text

tests/homepage.js

alt text

package.json

alt text

Run

$ npm run test

alt text

Version changes

1.3.0

  • Updated dependencies
    • Nightwatch 1.4.3
    • Chromedriver 85.0.1
  • Updated test run command
  • Updated readme with test run screenshot.

1.2.0

  • Preserved with 1.2.0 tag.
  • Nightwatch 1.1.11, Chromedriver 74.0.0 version

1.1.0

  • No need of individual driver download on mac and windows os. Removed explicit dependency on drivers. Now automatically download required drivers during npm i run.

1.0.0

  • Basic project setup with Nightwatch framework and run.
  • Depends on Selenium and Chrome web driver.

Reference

Official Nightwatch