Best for
- When setting up NightwatchJS for a new or existing project
- When writing end-to-end browser tests with Nightwatch
- When implementing Nightwatch page objects and commands
PramodDutta/qaskills/seed-skills/nightwatchjs-testing/SKILL.md
Comprehensive NightwatchJS end-to-end testing skill with integrated Selenium WebDriver, built-in assertions, page objects, and parallel test execution for reliable browser automation in JavaScript and TypeScript.
Decision brief
You are an expert QA engineer specializing in NightwatchJS end-to-end testing. When the user asks you to write, review, debug, or set up NightwatchJS-related tests or configurations, follow these detailed instructions.
Compatibility matrix
| Platform | Status | Evidence | What to check |
|---|---|---|---|
| Codex | Declared | Source record | Install path and trigger |
| Claude Code | Declared | Source record | Install path and trigger |
| Cursor | Declared | Source record | Install path and trigger |
| Gemini CLI | Not declared | No explicit evidence | Portability before use |
Installation
The source command is displayed only when detected. A safe inspection prompt is always available so your agent can explain every action before execution.
npx skills add https://github.com/PramodDutta/qaskills --skill "seed-skills/nightwatchjs-testing"Inspect the Agent Skill "NightwatchJS Testing" from https://github.com/PramodDutta/qaskills/blob/fb3fbec70591bad971dd97c5d9add6eaa99bae18/seed-skills/nightwatchjs-testing/SKILL.md at commit fb3fbec70591bad971dd97c5d9add6eaa99bae18. List every install step, command, network request, credential, file read/write, external action, and rollback step. Explain whether it fits my task. Do not install or execute anything until I approve.
Workflow
Review the “Setup” section in the pinned source before continuing.
1. Built-in Assertions First -- Use Nightwatch's rich built-in assertion library (.assert.visible(), .assert.textContains(), .assert.urlContains()) before reaching for custom assertion logic. 2. Page Object Architecture -- Structure all tests around Nightwatch's native page obje…
When setting up NightwatchJS for a new or existing project
Review the “Project Structure” section in the pinned source before continuing.
Review the “Configuration” section in the pinned source before continuing.
Permission review
The documentation includes network, browsing, or remote request actions.
launch_url: process.env.BASE_URL || 'http://localhost:3000',The documentation includes network, browsing, or remote request actions.
.assert.attributeContains('[data-testid="product-image"]', 'src', 'https://');The documentation asks the agent to run terminal commands or scripts.
**Use `--env` flag for multi-browser runs**: `npx nightwatch --env chrome,firefox` to execute tests across browsers in a single command.The documentation asks the agent to run terminal commands or scripts.
npx nightwatchThe documentation asks the agent to create, modify, or delete local files.
# Create configuration fileEvidence record
| Signal | Value | Evidence type | Meaning |
|---|---|---|---|
| Quality score | 92/100 | Computed | Documentation, specificity, maintenance, and trust rules |
| Repository stars | 211 | Source | Repository attention, not individual Skill quality |
| Compatibility | 3 platforms | Source | Declared in the catalog source record |
| Usage guide | automated source guide | Editorial | Generated or reviewed according to the visible evidence level |
Pinned source
You are an expert QA engineer specializing in NightwatchJS end-to-end testing. When the user asks you to write, review, debug, or set up NightwatchJS-related tests or configurations, follow these detailed instructions.
.assert.visible(), .assert.textContains(), .assert.urlContains()) before reaching for custom assertion logic.elements blocks and actions using commands.waitForConditionTimeout globally and use waitForElementVisible() for explicit synchronization.before, beforeEach, after, and afterEach hooks for setup/teardown rather than relying on test execution order.--parallel flag and ensure tests do not share mutable state.data-testid attributes and semantic selectors. Use Nightwatch's @element syntax from page objects to keep selectors centralized.'should display error when login fails with invalid credentials' rather than 'test login error'.nightwatch.conf.js, browser.url(), .assert, or .verify commandsproject-root/
├── nightwatch.conf.js # Main Nightwatch configuration
├── nightwatch/
│ ├── tests/ # Test spec files
│ │ ├── auth/
│ │ │ ├── login.ts
│ │ │ └── registration.ts
│ │ ├── checkout/
│ │ │ └── purchase-flow.ts
│ │ └── search/
│ │ └── product-search.ts
│ ├── page-objects/ # Page Object definitions
│ │ ├── loginPage.ts
│ │ ├── dashboardPage.ts
│ │ └── checkoutPage.ts
│ ├── custom-commands/ # Reusable custom commands
│ │ ├── loginViaApi.ts
│ │ └── clearSession.ts
│ ├── custom-assertions/ # Custom assertion definitions
│ │ └── elementHasCount.ts
│ ├── globals/ # Global hooks and settings
│ │ └── globals.ts
│ └── fixtures/ # Test data
│ └── users.json
├── reports/ # Test reports output
├── screenshots/ # Failure screenshots
└── package.json
module.exports = {
src_folders: ['nightwatch/tests'],
page_objects_path: ['nightwatch/page-objects'],
custom_commands_path: ['nightwatch/custom-commands'],
custom_assertions_path: ['nightwatch/custom-assertions'],
globals_path: 'nightwatch/globals/globals.js',
webdriver: {},
test_workers: {
enabled: true,
workers: 'auto',
},
test_settings: {
default: {
disable_error_log: false,
launch_url: process.env.BASE_URL || 'http://localhost:3000',
screenshots: {
enabled: true,
path: 'screenshots',
on_failure: true,
on_error: true,
},
desiredCapabilities: {
browserName: 'chrome',
'goog:chromeOptions': {
w3c: true,
args: process.env.CI
? ['--headless', '--no-sandbox', '--disable-gpu', '--disable-dev-shm-usage']
: [],
},
},
globals: {
waitForConditionTimeout: 10000,
retryAssertionTimeout: 5000,
},
},
firefox: {
desiredCapabilities: {
browserName: 'firefox',
'moz:firefoxOptions': {
args: process.env.CI ? ['--headless'] : [],
},
},
},
},
};
module.exports = {
url: function () {
return `${this.api.launchUrl}/login`;
},
elements: {
usernameInput: {
selector: '[data-testid="username-input"]',
},
passwordInput: {
selector: '[data-testid="password-input"]',
},
submitButton: {
selector: '[data-testid="login-submit"]',
},
errorMessage: {
selector: '[data-testid="login-error"]',
},
rememberMeCheckbox: {
selector: '[data-testid="remember-me"]',
},
},
commands: [
{
login(username, password) {
return this.waitForElementVisible('@usernameInput')
.clearValue('@usernameInput')
.setValue('@usernameInput', username)
.clearValue('@passwordInput')
.setValue('@passwordInput', password)
.click('@submitButton');
},
getErrorText(callback) {
return this.waitForElementVisible('@errorMessage').getText('@errorMessage', (result) => {
callback(result.value);
});
},
},
],
};
module.exports = {
url: function () {
return `${this.api.launchUrl}/dashboard`;
},
elements: {
welcomeMessage: '[data-testid="welcome-message"]',
userAvatar: '[data-testid="user-avatar"]',
logoutButton: '[data-testid="logout-btn"]',
widgetContainer: '[data-testid="dashboard-widgets"]',
notificationBadge: '[data-testid="notification-badge"]',
},
commands: [
{
waitForDashboardLoad() {
return this.waitForElementVisible('@welcomeMessage').waitForElementVisible(
'@widgetContainer'
);
},
logout() {
return this.click('@logoutButton');
},
},
],
};
describe('User Authentication', function () {
let loginPage;
let dashboardPage;
before(function (browser) {
loginPage = browser.page.loginPage();
dashboardPage = browser.page.dashboardPage();
});
it('should login with valid credentials', function () {
loginPage
.navigate()
.login('[email protected]', 'SecurePass123!')
.assert.urlContains('/dashboard');
dashboardPage.waitForDashboardLoad().assert.visible('@welcomeMessage');
});
it('should show error with invalid credentials', function (browser) {
loginPage.navigate().login('[email protected]', 'wrongpassword');
loginPage.getErrorText(function (text) {
browser.assert.ok(text.includes('Invalid email or password'));
});
});
it('should validate required fields', function () {
loginPage.navigate().click('@submitButton');
loginPage.assert.visible('@errorMessage');
});
after(function (browser) {
browser.end();
});
});
describe('Product Listing Page', function () {
it('should display products with correct structure', function (browser) {
browser
.url(`${browser.launchUrl}/products`)
.waitForElementVisible('[data-testid="product-grid"]')
.assert.elementPresent('[data-testid="product-card"]')
.assert.textContains('[data-testid="page-title"]', 'Products')
.assert.elementsCount('[data-testid="product-card"]', 12)
.assert.attributeContains('[data-testid="product-image"]', 'src', 'https://');
});
it('should filter products by category', function (browser) {
browser
.url(`${browser.launchUrl}/products`)
.waitForElementVisible('[data-testid="category-filter"]')
.click('[data-testid="category-electronics"]')
.waitForElementVisible('[data-testid="product-card"]')
.assert.textContains('[data-testid="active-filter"]', 'Electronics');
browser.elements('css selector', '[data-testid="product-card"]', function (result) {
this.assert.ok(result.value.length > 0, 'Should have filtered products');
});
});
it('should sort products by price', function (browser) {
browser
.url(`${browser.launchUrl}/products`)
.waitForElementVisible('[data-testid="sort-dropdown"]')
.click('[data-testid="sort-dropdown"]')
.click('[data-testid="sort-price-asc"]')
.pause(500) // Wait for re-render
.assert.textContains('[data-testid="sort-dropdown"]', 'Price: Low to High');
});
});
// nightwatch/custom-commands/loginViaApi.js
module.exports = {
command: async function (username, password) {
const baseUrl = this.api.launchUrl;
await this.execute(
function (url, user, pass) {
return fetch(`${url}/api/auth/login`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ email: user, password: pass }),
})
.then((res) => res.json())
.then((data) => {
document.cookie = `auth_token=${data.token}; path=/`;
return data;
});
},
[baseUrl, username, password]
);
return this.refresh();
},
};
// Usage in tests:
// browser.loginViaApi('[email protected]', 'AdminPass123!')
// .url(`${browser.launchUrl}/admin`)
// .assert.visible('[data-testid="admin-panel"]');
// nightwatch/custom-assertions/elementHasCount.js
exports.assertion = function (selector, expectedCount) {
this.message = `Testing if element <${selector}> appears ${expectedCount} times`;
this.expected = expectedCount;
this.pass = function (value) {
return value === expectedCount;
};
this.value = function (result) {
return result.value.length;
};
this.command = function (callback) {
return this.api.elements('css selector', selector, callback);
};
};
// Usage: browser.assert.elementHasCount('[data-testid="cart-item"]', 3)
describe('Cross-Browser Compatibility', function () {
it('should render header consistently', function (browser) {
browser
.url(browser.launchUrl)
.waitForElementVisible('[data-testid="site-header"]')
.assert.visible('[data-testid="logo"]')
.assert.visible('[data-testid="nav-menu"]')
.assert.cssProperty('[data-testid="site-header"]', 'display', 'flex');
});
});
@element syntax from page objects to keep selectors centralized and maintainable. Reference elements as '@usernameInput' rather than repeating raw selectors.waitForConditionTimeout globally in the globals section rather than adding explicit waits to every command.test_workers for parallel execution. Set workers: 'auto' to use all available CPU cores for maximum throughput.assert for hard assertions (fail immediately) and verify for soft assertions (continue execution and report at the end).screenshots configuration. Enable both on_failure and on_error for comprehensive visual debugging.--env flag for multi-browser runs: npx nightwatch --env chrome,firefox to execute tests across browsers in a single command.retryAssertionTimeout in globals to automatically retry failing assertions, which handles minor timing issues without explicit waits.browser.pause() for synchronization -- Arbitrary sleeps make tests slow and unreliable. Use waitForElementVisible() or waitForElementPresent() instead.before/beforeEach hooks for setup, not prior test results..verify when .assert is needed -- Soft assertions can mask failures. Use .assert for critical checks and .verify only when continuing execution is truly desired.browser.end() in teardown -- Not closing the browser session causes resource leaks and can make subsequent tests fail.# Run all tests
npx nightwatch
# Run specific test file
npx nightwatch nightwatch/tests/auth/login.ts
# Run tests in a specific folder
npx nightwatch --group auth
# Run tests matching a tag
npx nightwatch --tag smoke
# Run against specific browser
npx nightwatch --env firefox
# Run multi-browser
npx nightwatch --env chrome,firefox
# Run in parallel
npx nightwatch --parallel
# Run with verbose output
npx nightwatch --verbose
# Run specific test by name
npx nightwatch --testcase "should login with valid credentials"
# Initialize a new Nightwatch project
npm init nightwatch@latest
# Or install manually
npm install --save-dev nightwatch
# For Chrome testing
npm install --save-dev chromedriver
# For TypeScript support
npm install --save-dev typescript ts-node @types/nightwatch
# Create configuration file
npx nightwatch --init
Frequently asked questions
You are an expert QA engineer specializing in NightwatchJS end-to-end testing. When the user asks you to write, review, debug, or set up NightwatchJS-related tests or configurations, follow these detailed instructions.
The source record exposes this install command: npx skills add https://github.com/PramodDutta/qaskills --skill "seed-skills/nightwatchjs-testing". Inspect the command and pinned source before running it.
The pinned source record declares support for: codex, claude code, cursor.
Static rules flagged network, exec-script, write-files in the source; the page lists the matching lines and excerpts.
Alternatives
upex-galaxy/agentic-qa-boilerplate
Plan, write, and review automated tests following KATA (Komponent Action Test Architecture) on Playwright + TypeScript, or explain existing automated tests in a sealed read-only mode. Use when writing E2E or API/integration tests, creating Page or Api components, designing ATCs, parameterizing test data, registering fixtures, reviewing test code for KATA compliance, or requesting break-down-tests / a plain-English test breakdown. The explain mode reads source and reports assertions without enter
upex-galaxy/agentic-qa-boilerplate
Analyze, prioritize, and document test cases in TMS (Jira/Xray), or repair an existing Story-ATS-ATP-ATR-TC cascade through a sealed explicit mode. Use for Test/ATP/ATR artifacts, ROI and automation verdicts, maintaining traceability, fix-traceability, or broken TMS links. The repair-traceability mode audits, plans, waits for explicit approval, applies, and verifies without launching the general documentation workflow. Do NOT use for writing test code (test-automation) or running suites (regress
alirezarezvani/claude-skills
Use when planning, running, or learning from chaos engineering experiments. Triggers on "chaos experiment", "fault injection", "gameday", "resilience test", "blast radius", "steady state", "abort criteria", "Chaos Toolkit", "Chaos Mesh", "Litmus", "Gremlin", "AWS FIS", or any deliberate failure-injection question. Ships experiment designer, blast-radius calculator, and postmortem generator (all stdlib Python), 4 references on chaos principles + experiment design + attack taxonomy + tooling lands
PramodDutta/qaskills
Simulate aggressive user behavior patterns including rapid clicking, random navigation, form abuse, tab spamming, and unexpected interaction sequences to find UI resilience issues