Registry / testing / vite-plugin-nightwatch

vite-plugin-nightwatch

JSON →
library0.4.6jsnpmunverified

Integrates Vite with Nightwatch.js for component testing. Version 0.4.6, latest stable, released 2023. Supports Vue and React components. Enables mounting components, mocking fetch calls, and importing custom scripts. Requires Vite dev server running. Distinct from Cypress/Playwright: uses Nightwatch's native API with simplified setup.

npm install vite-plugin-nightwatch
INSTALL
IMPORT
SIG · VITE-PLUGIN-NIGHTW
V
vite-plugin-nightwatch
testingjavascriptv0.4.6
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default (nightwatchPlugin)
import nightwatchPlugin from 'vite-plugin-nightwatch'
import { nightwatchPlugin } from 'vite-plugin-nightwatch'
Default export only; named export not available.
NightwatchPluginConfig
import type { NightwatchPluginConfig } from 'vite-plugin-nightwatch'
Type import for config options.
browser.mountVueComponent
browser.mountVueComponent('/src/components/Form.vue', { props: { ... } })
browser.mountVueComponent({componentPath: '...'})
Method on Nightwatch browser object, not a direct import.

Setup Vite config with nightwatch plugin and write a basic component test.

// vite.config.ts import { defineConfig } from 'vite'; import vue from '@vitejs/plugin-vue'; import nightwatchPlugin from 'vite-plugin-nightwatch'; export default defineConfig({ plugins: [ vue(), nightwatchPlugin({ componentType: 'vue' }) ] }); // nightwatch.conf.js module.exports = { src_folders: ['tests'], page_objects_path: [], custom_commands_path: [], custom_assertions_path: [], plugins: ['vite-plugin-nightwatch'], vite_dev_server: { start_vite: true, port: 5173 }, launchUrl: 'http://localhost:5173' }; // tests/example.spec.js module.exports = { 'test vue component': function (browser) { browser .launchComponentRenderer() .importScript('/src/components/Form.vue') .waitForElementVisible('.form') .assert.textContains('.form h1', 'Hello') .end(); } };
Debug
Known issues
breakingPlugin may not work with Vite 4+ if nightwatch.config not properly set
fix
Ensure launchUrl matches Vite dev server port and vite_dev_server.start_vite is true.
affects: >=0.4.0
gotchamountVueComponent and mountReactComponent must be used after launchComponentRenderer
fix
Call browser.launchComponentRenderer() before mounting.
affects: >=0.2.0
gotchaimportScript requires ESM format scripts; CJS will fail silently
fix
Use ESM or convert script to .mjs.
affects: >=0.2.0
breakingDefault componentType changed from 'vue' to require explicit setting
fix
Explicitly set componentType: 'vue' or 'react' in plugin options.
affects: >=0.3.0
deprecatedbrowser.mountReactComponent props parameter is an object, not array
fix
Pass props as object: { name: 'value' }.
affects: >=0.2.0
Errors
Common errors & fixes
Error: Cannot find module 'vite-plugin-nightwatch'
Missing dependency installation
fix
Run: npm install vite-plugin-nightwatch --save-dev
TypeError: browser.mountVueComponent is not a function
Missing Nightwatch plugin registration
fix
Add 'vite-plugin-nightwatch' to plugins array in nightwatch.conf.js
Error: launch_url is not defined
Missing launchUrl or baseUrl in config
fix
Set launchUrl: 'http://localhost:5173' in nightwatch.conf.js
Upgrade
Version history
0.4.6latest on npm
Audit
Dependencies
nightwatchrequiredPeer dependency for Nightwatch API commands
Agent activity
11 hits · last 30 days
node
10
OpenAI (training)
1
Resources
vite-plugin-nightwatch — npm install vite-plugin-nightwatch · libregistry