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
muslnode 18–226 runs
build_error
glibcnode 18–226 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.fixMigrate 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.fixDowngrade 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.fixAvoid 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.fixThis 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.
fixEnsure `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.
fixVerify 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.
fixThis 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.
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.