Registry / testing / mocha-nightwatch

mocha-nightwatch

JSON →
library3.2.2jsnpmunverified

The `mocha-nightwatch` package serves as an adapter, enabling the use of Mocha's familiar BDD/TDD syntax, such as `describe` and `it`, within the Nightwatch.js end-to-end testing framework. This allows developers to structure their Nightwatch tests using Mocha's expressive assertion style and test organization patterns. The package is currently at version 3.2.2. However, it is important to note that this adapter has not been updated in over five years, with its last publication in October 2019. It relies on significantly older versions of its core dependencies, specifically Mocha (~3.2.0) and Nightwatch.js (~0.9.12). Consequently, its release cadence is non-existent, and it is incompatible with modern versions of Node.js, Nightwatch.js (v1.x, v2.x, v3.x+), and Mocha (v4.x+). Key differentiators, at the time of its relevance, included bridging two popular testing paradigms for browser automation, but its abandonment makes it unsuitable for current development.

npm install mocha-nightwatch
INSTALL
IMPORT
SIG · MOCHA-NIGHTWATCH
M
mocha-nightwatch
testingjavascriptv3.2.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

describe
/* Used globally or implicitly by Mocha test runner */
import { describe } from 'mocha-nightwatch'
While 'describe' is a core Mocha function, it's typically available globally in a Mocha test environment or implicitly provided by the test runner, not directly imported from `mocha-nightwatch`. This package facilitates Mocha's usage with Nightwatch.
it
/* Used globally or implicitly by Mocha test runner */
import { it } from 'mocha-nightwatch'
Similar to 'describe', 'it' is a Mocha global for defining individual test cases and is made available by the test runner setup, not directly through an import from `mocha-nightwatch`.
browser
/* Injected as a parameter into test functions */
import { browser } from 'mocha-nightwatch'
The 'browser' (or 'client') object is a Nightwatch.js global or an argument passed to test functions, providing access to browser commands and assertions. It's not a direct import from `mocha-nightwatch` but a core Nightwatch feature used within tests that this adapter enables.

Demonstrates how to configure Nightwatch.js to use Mocha as its test runner and write a basic end-to-end test. Ensure 'chromedriver' and 'nightwatch@~0.9.12' are installed.

// nightwatch.conf.js const chromedriver = require('chromedriver'); module.exports = { src_folders: ["test"], output_folder: "reports", globals_path: "globals.js", test_runner: { type: "mocha", options: { ui: "bdd", reporter: "spec", timeout: "60000" } }, webdriver: { start_process: true, port: 9515, server_path: chromedriver.path, // Requires 'chromedriver' package cli_args: [ "--verbose" ] }, test_settings: { default: { launch_url: "http://localhost", desiredCapabilities: { browserName: "chrome", javascriptEnabled: true, acceptSslCerts: true, chromeOptions: { args: ["--headless"] } } } } }; // test/example.spec.js describe('Google Homepage Test', function() { it('should have a title', function(browser) { browser .url('https://www.google.com') .waitForElementVisible('body', 1000) .assert.titleContains('Google') .end(); }); it('should find the search input', function(browser) { browser .url('https://www.google.com') .waitForElementVisible('input[name="q"]', 1000) .assert.elementPresent('input[name="q"]') .end(); }); });
Debug
Known issues
breakingThis package is incompatible with Nightwatch.js versions 1.x, 2.x, or 3.x and relies on the severely outdated Nightwatch.js ~0.9.12 API.
fix
Migrate your test suite to use Nightwatch.js's native test runners (e.g., Cucumber.js, Jest) or find a currently maintained adapter if available. Downgrading Nightwatch.js to a pre-1.0 version is not recommended.
affects: >=1.0.0 (Nightwatch.js)
breakingThis adapter is not compatible with Mocha versions 4.x and above, as it was designed for Mocha ~3.2.0. Significant breaking changes occurred in later Mocha releases.
fix
Downgrade Mocha to a compatible version (e.g., `mocha@3.2.0`) if you must use this adapter. Otherwise, rewrite your tests for a modern test runner.
affects: >=4.0.0 (Mocha)
gotchaThe `mocha-nightwatch` package is effectively abandoned, with its last update over five years ago. It is highly unlikely to function correctly with modern Node.js versions, browser versions, or current versions of its dependencies.
fix
Avoid using this package for any new development. For existing projects, prioritize migrating to a actively maintained testing framework and setup.
affects: *
gotchaThe package requires Node.js >=0.10.x, an end-of-life Node.js release. Running it on modern Node.js LTS versions (e.g., v14+) will likely result in runtime errors or unexpected behavior due to API changes and deprecations.
fix
This package is not compatible with modern Node.js. If forced to use it, you would need to run an extremely old, unsupported Node.js version, which is a significant security risk and not recommended.
affects: >=12.0.0 (Node.js)
Errors
Common errors & fixes
Error: The `nightwatch` dependency is not installed.
Nightwatch.js is either missing from the project or installed at an incompatible version that the adapter cannot detect.
fix
Ensure `nightwatch@~0.9.12` is explicitly installed in your project: `npm install nightwatch@~0.9.12`.
ReferenceError: describe is not defined
The Mocha test runner environment has not been correctly initialized, preventing global test functions from being exposed.
fix
Verify that `test_runner.type` is explicitly set to 'mocha' in your `nightwatch.conf.js` file and that `mocha@~3.2.0` is installed as a dependency.
TypeError: browser.url is not a function
This error or similar 'browser' object method failures typically indicate an incompatibility between the old Nightwatch.js API expected by the adapter and a newer Nightwatch.js version being used.
fix
This adapter strictly supports Nightwatch.js <=0.9.12. Ensure `nightwatch@~0.9.12` is installed and that your `nightwatch.conf.js` correctly configures the Mocha test runner for this specific version.
Upgrade
Version history
3.2.2latest on npm
Audit
Dependencies
mocharequiredProvides the BDD/TDD test syntax and runner features for tests written with the adapter.
nightwatchrequiredProvides the browser automation, page object model, and assertion capabilities for end-to-end tests.
Agent activity
2 hits · last 30 days
node
2
Resources
mocha-nightwatch — npm install mocha-nightwatch · libregistry