Principle:Nightwatchjs Nightwatch Extension Usage In Tests
| Knowledge Sources | |
|---|---|
| Domains | Testing, Extensibility |
| Last Updated | 2026-02-12 00:00 GMT |
Overview
A test integration pattern for invoking registered custom commands and assertions alongside built-in API methods.
Description
Extension Usage in Tests describes how custom commands and assertions are consumed in test code. Custom commands are called on the browser object exactly like built-in commands, making them first-class API members. Custom assertions are invoked via browser.assert.assertionName() or browser.verify.assertionName(). The seamless integration means tests do not need to import or require custom extensions; they are available immediately after configuration.
Usage
Use custom commands and assertions in tests the same way you use built-in ones. No import statements are needed.
Theoretical Basis
The extension integration principle follows the uniform API pattern:
- Custom commands are indistinguishable from built-in commands at the call site
- Custom assertions appear on both assert (strict) and verify (lenient) namespaces
- Method signatures are defined by the extension author
- Chaining works identically to built-in commands