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

cucumber-nightwatch

v1.0.1

Published

A small library to enable us to use nightwatch.js in cucumber.js

Downloads

4

Readme

cucumber-nightwatch 🥒 + 🦉

Test npm version

A small library to enable us to use latest nightwatch.js(v3) in cucumber.js(v9)

screenshot

Installation

npm install @cucumber/cucumber nightwatch cucumber-nightwatch

Cucumber configuration

Before start, please follow the Cucumber-js document to setup your Cucumber-js. After that, then add below in your Cucumber-js hooks file.

const{
  Before,
  After
} = require('@cucumber/cucumber')
const { NightwatchWorld } = require('cucumber-nightwatch')

setWorldConstructor(NightwatchWorld)

// Launch the browser session before each test scenario
Before(async function () {
  await this.initNightwatch()
})

// Close the browser session after each test scenario
After(async function () {
  await this.endNightwatch()
})

If you are using TypeScript, use below examples:

import {
  Before,
  After
} from '@cucumber/cucumber'
import NightwatchWorld from 'cucumber-nightwatch'

setWorldConstructor(NightwatchWorld)

// Launch the browser session before each test scenario
Before(async function (this: NightwatchWorld) {
  await this.initNightwatch()
})

// Close the browser session after each test scenario
After(async function (this: NightwatchWorld) {
  await this.endNightwatch()
})

Step definitions

After we have the above cucumber hooks setup completed. We can write step definition to use Nightwatch.js like below examples.

JavaScript:

Given('I visit the Google AU homepage', function () {
  this.browser.url('https://google.com.au')
})

When('I check the page title', async function () {
  this.pageTitle = await this.browser.getTitle()
})

Then('the title text should be {string}', async function (title) {
  await this.browser.assert.equal(this.pageTitle, title)
})

TypeScript:

import NightwatchWorld from 'cucumber-nightwatch'

Given('I visit the Google AU homepage', function (this: NightwatchWorld) {
  this.browser!.url('https://google.com.au')
})

When('I check the page title', async function (this: NightwatchWorld) {
  this.pageTitle = await this.browser!.getTitle()
})

Then('the title text should be {string}', async function (this: NightwatchWorld, title: string) {
  await this.browser!.assert.equal(this.pageTitle, title)
})

Run tests

Run tests by using cucumber-js

npx cucumber-js

Run with cucumber-js options

npx cucumber-js --tags "@regression" --parallel 4 --retry 2 

More details can be found in cucumber-js CLI

Nightwatch configuration

There is no configurations required to run the tests by default.

You will need to setup Nigthwatch.js configuration file first. If you don't have one in project root dir, the first time run should generate one for you automatically.

But you can use below optional environment variables to configure the Nightwatch runner options

# Specify your testing environment to use, same as --env
NIGHTWATCH_BROWSER=chrome
# Default is false. Set to true to enable --headless
NIGHTWATCH_HEADLESS=true
# Default is using root config file. --config
NIGHTWATCH_CONFIG=./custom_dir/nightwatch.conf.js
# Default is 10000ms. --timeout
NIGHTWATCH_TIMEOUT=10000
# Default is true. Set to false to enable --verbose
NIGHTWATCH_SILENT=false
# Default is false. Set to true to enable logs
NIGHTWATCH_OUTPUT=true
# Default is true. Set to false to disable parallel. If you run cucumber-js in parallel, this need to be true.
NIGHTWATCH_PARALLEL=false

Cucumber Nightwatch configuration

# Enable verbose log to see how nightwatch browser start and exit
CN_DEBUG=true

Known issues 🐛

There are some bugs in Nightwatch.js programmatic API. See https://github.com/tim-yao/cucumber-nightwatch/issues/6