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
npx skills add LambdaTest/agent-skills --skill nightwatchjs-skill -a claude-codeWhat 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
/dashboardredirect - Move selectors and steps into a
pages/loginPage.jspage object - Point a test run at the LambdaTest cloud through the
lambdatestenvironment - 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
/dashboardredirect. - Move the login steps into a
pages/loginPage.jspage object and reuse it. - Set up
nightwatch.conf.jsso the suite runs on LambdaTest.
How to install nightwatchjs-skill
1Skills CLI (Vercel)
npx skills add LambdaTest/agent-skills --skill nightwatchjs-skill -a claude-code2Manually: put the files in place
~/.claude/skills/nightwatchjs-skill/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/nightwatchjs-skill/
1Skills CLI (Vercel)
npx skills add LambdaTest/agent-skills --skill nightwatchjs-skill -a codex2Manually: put the files in place
.agents/skills/nightwatchjs-skill/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add LambdaTest/agent-skills --skill nightwatchjs-skill -a cursor2Manually: put the files in place
.cursor/skills/nightwatchjs-skill/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install LambdaTest/agent-skills nightwatchjs-skill2Manually: put the files in place
.github/skills/nightwatchjs-skill/SKILL.md1Skills CLI (Vercel)
npx skills add LambdaTest/agent-skills --skill nightwatchjs-skill -a gemini-cli2Platform CLI
gemini skills install https://github.com/LambdaTest/agent-skills --path nightwatchjs-skillManually: put the files in place
.devin/skills/nightwatchjs-skill/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add LambdaTest/agent-skills --skill nightwatchjs-skill -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
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