Skip to main content
skill CX Codex

nightwatchjs-skill — Claude Code skill: NightwatchJS E2E tests

Writes NightwatchJS E2E tests in JavaScript or TypeScript, with page objects and built-in assertions. Fits repos that already run Nightwatch.

MIT 208 installs ★ 393 updated 2026-10-13

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add LambdaTest/agent-skills --skill nightwatchjs-skill -a claude-code
Open on GitHub

What nightwatchjs-skill does

This skill produces NightwatchJS E2E tests for JavaScript or TypeScript projects. It asks where to run first: local drivers (ChromeDriver or GeckoDriver) or a cloud grid when you name TestMu or LambdaTest. Silence means local.

Patterns come ready-made. A basic test chains browser.url(), waitForElementVisible(), setValue() and closes with assert. Page objects live under pages/ — loginPage.js holds its elements plus a login(email, password) command the test calls later. Assertions ship in the runner: assert.containsText, assert.urlContains, assert.elementsCount. One section covers nightwatch.conf.js with a lambdatest environment and LT:Options.

Setup is npm install nightwatch --save-dev; run npx nightwatch, or npx nightwatch --env lambdatest for the cloud. Cloud runs read LT_USERNAME and LT_ACCESS_KEY from the environment, and the LT:Options block will not authenticate without them. Deeper patterns, debugging and CI notes sit in reference/playbook.md.

What it helps with

  • Generate a login E2E test that asserts the /dashboard redirect
  • Move selectors and steps into a pages/loginPage.js page object
  • Point a test run at the LambdaTest cloud through the lambdatest environment
  • Add text, URL and element-count assertions to an existing test
  • Turn a manual checklist into Nightwatch test cases

Example prompts for the agent

  • Write a NightwatchJS E2E test for login with valid credentials and check the /dashboard redirect.
  • Move the login steps into a pages/loginPage.js page object and reuse it.
  • Set up nightwatch.conf.js so the suite runs on LambdaTest.

How to install nightwatchjs-skill

1Skills CLI (Vercel)

npx skills add LambdaTest/agent-skills --skill nightwatchjs-skill -a claude-code

2Manually: put the files in place

~/.claude/skills/nightwatchjs-skill/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/nightwatchjs-skill/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about nightwatchjs-skill

How do I install nightwatchjs-skill in Claude Code?

Run npx skills add LambdaTest/agent-skills --skill nightwatchjs-skill -a claude-code. The skill file lands at ~/.claude/skills/nightwatchjs-skill/SKILL.md.

What does nightwatchjs-skill do?

It generates NightwatchJS E2E tests: browser action chains, page objects and built-in assertions. It also assembles the config for a local or cloud run.

What is required for cloud test runs?

LT_USERNAME and LT_ACCESS_KEY in the environment. The lambdatest environment in nightwatch.conf.js points at hub.lambdatest.com and cannot authenticate without them.

Source text

SKILL.md · MIT
---
name: nightwatchjs-skill
description: >
  Generates NightwatchJS E2E tests in JavaScript. Integrated test runner with
  Selenium WebDriver, built-in assertions, and page objects. Use when user
  mentions "Nightwatch", "NightwatchJS", "nightwatch.conf.js". Triggers on:
  "Nightwatch", "NightwatchJS", "nightwatch test".
languages:
  - JavaScript
  - TypeScript
category: e2e-testing
license: MIT
metadata:
  author: TestMu AI
  version: "1.0"
---

# NightwatchJS Automation Skill

## Step 1 — Execution Target

```
├─ "cloud", "TestMu", "LambdaTest" → Cloud: nightwatch.conf.js with LT env
├─ "local" → Local: ChromeDriver/GeckoDriver
└─ Default → Local, mention cloud option
```

## Core Patterns

### Basic Test

```javascript
module.exports = {
  'Login with valid credentials': function(browser) {
    browser
      .url('http://localhost:3000/login')
      .waitForElementVisible('#email', 5000)
      .setValue('#email', '[email protected]')
      .setValue('#password', 'password123')
      .click('button[type="submit"]')
      .waitForElementVisible('.dashboard', 10000)
      .assert.containsText('.welcome', 'Welcome')
      .assert.urlContains('/dashboard')
      .end();
  },

  'Login with invalid credentials shows error': function(browser) {
    browser
      .url('http://localhost:3000/login')
      .waitForElementVisible('#email', 5000)
      .setValue('#email', '[email protected]')
      .setValue('#password', 'wrong')
      .click('button[type="submit"]')
      .waitForElementVisible('.error-message', 5000)
      .assert.containsText('.error-message', 'Invalid credentials')
      .end();
  }
};
```

### Page Objects

```javascript
// pages/loginPage.js
module.exports = {
  url: '/login',
  elements: {
    emailInput: '#email',
    passwordInput: '#password',
    loginButton: 'button[type="submit"]',
    errorMessage: '.error-message',
  },
  commands: [{
    login(email, password) {
      return this
        .setValue('@emailInput', email)
        .setValue('@passwordInput', password)
        .click('@loginButton');
    }
  }]
};

// tests/loginTest.js
module.exports = {
  'Login test': function(browser) {
    const login = browser.page.loginPage();
    login.navigate()
      .login('[email protected]', 'password123');
    browser.assert.urlContains('/dashboard');
  }
};
```

### Assertions

```javascript
browser.assert.visible(selector);
browser.assert.not.visible(selector);
browser.assert.containsText(selector, 'text');
browser.assert.urlContains('/path');
browser.assert.titleContains('Page Title');
browser.assert.elementPresent(selector);
browser.assert.cssClassPresent(selector, 'active');
browser.assert.value('#input', 'expected');
browser.assert.attributeEquals(selector, 'href', '/link');
browser.assert.elementsCount('li', 5);
```

### TestMu AI Cloud Config

For full capabilities and shared reference, see [reference/cloud-integration.md](reference/cloud-integration.md).

```javascript
// nightwatch.conf.js
module.exports = {
  test_settings: {
    default: {
      launch_url: 'http://localhost:3000',
      desiredCapabilities: { browserName: 'chrome' }
    },
    lambdatest: {
      selenium: {
        host: 'hub.lambdatest.com',
        port: 80
      },
      desiredCapabilities: {
        browserName: 'chrome',
        browserVersion: 'latest',
        'LT:Options': {
          platform: 'Windows 11',
          build: 'Nightwatch Build',
          name: 'Login Tests',
          user: process.env.LT_USERNAME,
          accessKey: process.env.LT_ACCESS_KEY,
          video: true, console: true, network: true
        }
      }
    }
  },
  page_objects_path: ['pages/'],
};
```

## Setup: `npm install nightwatch --save-dev`
## Run: `npx nightwatch` or `npx nightwatch --env lambdatest`

## Deep Patterns

For advanced patterns, debugging guides, CI/CD integration, and best practices,
see `reference/playbook.md`.

© TestMu AI · MIT · LambdaTest/agent-skills

Similar skills

All skills for Testing and QA →

From the same set47

The whole set →
geb-skill This skill generates browser automation tests in Groovy using Geb and Spock. It provides page object patterns and jQuery-like selectors for e2e testing. CX Codex +1 211installs capybara-skill Generates acceptance tests for web apps using Capybara and RSpec. Use it to automate clicks, form fills, and page assertions in Ruby-based E2E suites. CX Codex +1 210installs nunit-skill Generates C# unit tests for NUnit 3 using the Assert.That constraint model, parameterized inputs, and Moq mocks. CX Codex +1 210installs mstest-skill This skill generates MSTest unit tests in C# for .NET. Use it when a task calls for [TestMethod], assertion checks, or data-driven cases. CX Codex +1 209installs nemojs-skill The nemojs-skill skill generates JavaScript automation tests for Nemo.js and Selenium. Use it for browser flows such as login checks, element waits, and assertions. CX Codex +1 209installs lettuce-skill Generates Python BDD tests using the legacy Lettuce framework. Builds Gherkin feature files, step definitions, and terrain hooks for existing test suites. CX Codex +1 208installs protractor-skill protractor-skill is a Claude Code skill that writes Protractor E2E tests for Angular and AngularJS apps in JavaScript or TypeScript. It activates on requests about Protractor, element(by.model()), or Angular E2E testing. CX Codex +1 206installs reqnroll-skill Generates production-grade Reqnroll BDD tests in C# for Selenium and Appium 2. Helps configure parallel NUnit suites and cloud runs on LambdaTest. CX Codex +1 138installs

Project sponsors

Companies that keep this analytics open