{"id":14710,"library":"mocha-nightwatch","title":"Mocha Adapter for Nightwatch.js","description":"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.","status":"abandoned","version":"3.2.2","language":"javascript","source_language":"en","source_url":"git://github.com/nightwatchjs/mocha-nightwatch","tags":["javascript","mocha","test","bdd","tdd","tap","nightwatch"],"install":[{"cmd":"npm install mocha-nightwatch","lang":"bash","label":"npm"},{"cmd":"yarn add mocha-nightwatch","lang":"bash","label":"yarn"},{"cmd":"pnpm add mocha-nightwatch","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Provides the BDD/TDD test syntax and runner features for tests written with the adapter.","package":"mocha","optional":false},{"reason":"Provides the browser automation, page object model, and assertion capabilities for end-to-end tests.","package":"nightwatch","optional":false}],"imports":[{"note":"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.","wrong":"import { describe } from 'mocha-nightwatch'","symbol":"describe","correct":"/* Used globally or implicitly by Mocha test runner */"},{"note":"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`.","wrong":"import { it } from 'mocha-nightwatch'","symbol":"it","correct":"/* Used globally or implicitly by Mocha test runner */"},{"note":"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.","wrong":"import { browser } from 'mocha-nightwatch'","symbol":"browser","correct":"/* Injected as a parameter into test functions */"}],"quickstart":{"code":"// nightwatch.conf.js\nconst chromedriver = require('chromedriver');\n\nmodule.exports = {\n  src_folders: [\"test\"],\n  output_folder: \"reports\",\n  globals_path: \"globals.js\",\n\n  test_runner: {\n    type: \"mocha\",\n    options: {\n      ui: \"bdd\",\n      reporter: \"spec\",\n      timeout: \"60000\"\n    }\n  },\n\n  webdriver: {\n    start_process: true,\n    port: 9515,\n    server_path: chromedriver.path, // Requires 'chromedriver' package\n    cli_args: [\n      \"--verbose\"\n    ]\n  },\n\n  test_settings: {\n    default: {\n      launch_url: \"http://localhost\",\n      desiredCapabilities: {\n        browserName: \"chrome\",\n        javascriptEnabled: true,\n        acceptSslCerts: true,\n        chromeOptions: {\n          args: [\"--headless\"]\n        }\n      }\n    }\n  }\n};\n\n// test/example.spec.js\n\ndescribe('Google Homepage Test', function() {\n  it('should have a title', function(browser) {\n    browser\n      .url('https://www.google.com')\n      .waitForElementVisible('body', 1000)\n      .assert.titleContains('Google')\n      .end();\n  });\n\n  it('should find the search input', function(browser) {\n    browser\n      .url('https://www.google.com')\n      .waitForElementVisible('input[name=\"q\"]', 1000)\n      .assert.elementPresent('input[name=\"q\"]')\n      .end();\n  });\n});\n","lang":"javascript","description":"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."},"warnings":[{"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.","message":"This 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.","severity":"breaking","affected_versions":">=1.0.0 (Nightwatch.js)"},{"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.","message":"This 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.","severity":"breaking","affected_versions":">=4.0.0 (Mocha)"},{"fix":"Avoid using this package for any new development. For existing projects, prioritize migrating to a actively maintained testing framework and setup.","message":"The `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.","severity":"gotcha","affected_versions":"*"},{"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.","message":"The 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.","severity":"gotcha","affected_versions":">=12.0.0 (Node.js)"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Ensure `nightwatch@~0.9.12` is explicitly installed in your project: `npm install nightwatch@~0.9.12`.","cause":"Nightwatch.js is either missing from the project or installed at an incompatible version that the adapter cannot detect.","error":"Error: The `nightwatch` dependency is not installed."},{"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.","cause":"The Mocha test runner environment has not been correctly initialized, preventing global test functions from being exposed.","error":"ReferenceError: describe is not defined"},{"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.","cause":"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.","error":"TypeError: browser.url is not a function"}],"ecosystem":"npm"}