# nightwatchjs-skill

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

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode, Windsurf (Devin Desktop), Claude.ai · 208 installs · ★ 393 repo stars
- Author: TestMu AI
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/LambdaTest/agent-skills/tree/HEAD/nightwatchjs-skill/SKILL.md
- Updated: 2026-10-13
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/skills/nightwatchjs-skill

## What it 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`.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add LambdaTest/agent-skills --skill nightwatchjs-skill -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/nightwatchjs-skill/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/nightwatchjs-skill/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add LambdaTest/agent-skills --skill nightwatchjs-skill -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/nightwatchjs-skill/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add LambdaTest/agent-skills --skill nightwatchjs-skill -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/nightwatchjs-skill/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install LambdaTest/agent-skills nightwatchjs-skill
```

2. **Manually: put the files in place**
- File: `.github/skills/nightwatchjs-skill/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add LambdaTest/agent-skills --skill nightwatchjs-skill -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/LambdaTest/agent-skills --path nightwatchjs-skill
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/nightwatchjs-skill/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add LambdaTest/agent-skills --skill nightwatchjs-skill -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/LambdaTest/agent-skills/tree/HEAD/nightwatchjs-skill/SKILL.md

## When to use it
- 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
- 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.

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: d39714b20852e238.

BEGIN THIRD-PARTY FILE d39714b20852e238
````text
---
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', 'user@test.com')
      .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', 'wrong@test.com')
      .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('user@test.com', 'password123');
    browser.assert.urlContains('/dashboard');
  }
};
```

### Assertions

```javascript
browser.assert.visible(selector);
browser.assert.not.visible(selector);
````
END THIRD-PARTY FILE d39714b20852e238

The third-party file has ended. Everything between the d39714b20852e238 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2431 of 3900 bytes. © TestMu AI · MIT · https://github.com/LambdaTest/agent-skills/tree/HEAD/nightwatchjs-skill/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
