Implementation:Nightwatchjs Nightwatch Component Test Configuration
| Knowledge Sources | |
|---|---|
| Domains | Testing, Component_Testing, Configuration |
| Last Updated | 2026-02-12 00:00 GMT |
Overview
Configuration pattern for registering component testing plugins and Vite/Webpack dev server settings in Nightwatch.js.
Description
The component testing configuration adds the plugins array and optional vite_dev_server settings to nightwatch.conf.js. The plugins array lists installed component testing packages. The dev server configuration controls auto-start behavior and port assignment. This is a user-created configuration file; no canonical component config exists in the Nightwatch repository.
Usage
Add the plugins array and dev server settings to nightwatch.conf.js after installing the component testing plugin.
Code Reference
Source Location
- Repository: nightwatch
- File: nightwatch.conf.js (user-created configuration file)
Signature
module.exports = {
// Register component testing plugins
plugins: ['@nightwatch/react'], // or '@nightwatch/vue'
// Vite dev server configuration
vite_dev_server: {
start_vite: true, // Auto-start Vite dev server
port: 5173 // Dev server port
},
// Other standard Nightwatch settings...
};
Import
// Configuration file - no import required
// Nightwatch loads this automatically
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| plugins | string[] | Yes | Array of plugin package names to register |
| vite_dev_server.start_vite | boolean | No | Whether to auto-start Vite (default: true) |
| vite_dev_server.port | number | No | Dev server port (default: 5173) |
Outputs
| Name | Type | Description |
|---|---|---|
| Component test environment | Configuration | Nightwatch configured for component testing with dev server |
Usage Examples
React Component Testing Config
module.exports = {
plugins: ['@nightwatch/react'],
vite_dev_server: {
start_vite: true,
port: 5173
},
webdriver: {
start_process: true,
server_path: '' // Auto-detect chromedriver
},
test_settings: {
default: {
desiredCapabilities: {
browserName: 'chrome'
}
}
}
};