{"id":22754,"library":"vite-plugin-nightwatch","title":"vite-plugin-nightwatch","description":"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.","status":"active","version":"0.4.6","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/nightwatchjs/vite-plugin-nightwatch","tags":["javascript","nightwatch","nightwatch.js","vite","component test","component-testing","vue","react","typescript"],"install":[{"cmd":"npm install vite-plugin-nightwatch","lang":"bash","label":"npm"},{"cmd":"yarn add vite-plugin-nightwatch","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-plugin-nightwatch","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency for Nightwatch API commands","package":"nightwatch","optional":false}],"imports":[{"note":"Default export only; named export not available.","wrong":"import { nightwatchPlugin } from 'vite-plugin-nightwatch'","symbol":"default (nightwatchPlugin)","correct":"import nightwatchPlugin from 'vite-plugin-nightwatch'"},{"note":"Type import for config options.","wrong":null,"symbol":"NightwatchPluginConfig","correct":"import type { NightwatchPluginConfig } from 'vite-plugin-nightwatch'"},{"note":"Method on Nightwatch browser object, not a direct import.","wrong":"browser.mountVueComponent({componentPath: '...'})","symbol":"browser.mountVueComponent","correct":"browser.mountVueComponent('/src/components/Form.vue', { props: { ... } })"}],"quickstart":{"code":"// vite.config.ts\nimport { defineConfig } from 'vite';\nimport vue from '@vitejs/plugin-vue';\nimport nightwatchPlugin from 'vite-plugin-nightwatch';\n\nexport default defineConfig({\n  plugins: [\n    vue(),\n    nightwatchPlugin({\n      componentType: 'vue'\n    })\n  ]\n});\n\n// nightwatch.conf.js\nmodule.exports = {\n  src_folders: ['tests'],\n  page_objects_path: [],\n  custom_commands_path: [],\n  custom_assertions_path: [],\n  plugins: ['vite-plugin-nightwatch'],\n  vite_dev_server: {\n    start_vite: true,\n    port: 5173\n  },\n  launchUrl: 'http://localhost:5173'\n};\n\n// tests/example.spec.js\nmodule.exports = {\n  'test vue component': function (browser) {\n    browser\n      .launchComponentRenderer()\n      .importScript('/src/components/Form.vue')\n      .waitForElementVisible('.form')\n      .assert.textContains('.form h1', 'Hello')\n      .end();\n  }\n};","lang":"typescript","description":"Setup Vite config with nightwatch plugin and write a basic component test."},"warnings":[{"fix":"Ensure launchUrl matches Vite dev server port and vite_dev_server.start_vite is true.","message":"Plugin may not work with Vite 4+ if nightwatch.config not properly set","severity":"breaking","affected_versions":">=0.4.0"},{"fix":"Call browser.launchComponentRenderer() before mounting.","message":"mountVueComponent and mountReactComponent must be used after launchComponentRenderer","severity":"gotcha","affected_versions":">=0.2.0"},{"fix":"Use ESM or convert script to .mjs.","message":"importScript requires ESM format scripts; CJS will fail silently","severity":"gotcha","affected_versions":">=0.2.0"},{"fix":"Explicitly set componentType: 'vue' or 'react' in plugin options.","message":"Default componentType changed from 'vue' to require explicit setting","severity":"breaking","affected_versions":">=0.3.0"},{"fix":"Pass props as object: { name: 'value' }.","message":"browser.mountReactComponent props parameter is an object, not array","severity":"deprecated","affected_versions":">=0.2.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run: npm install vite-plugin-nightwatch --save-dev","cause":"Missing dependency installation","error":"Error: Cannot find module 'vite-plugin-nightwatch'"},{"fix":"Add 'vite-plugin-nightwatch' to plugins array in nightwatch.conf.js","cause":"Missing Nightwatch plugin registration","error":"TypeError: browser.mountVueComponent is not a function"},{"fix":"Set launchUrl: 'http://localhost:5173' in nightwatch.conf.js","cause":"Missing launchUrl or baseUrl in config","error":"Error: launch_url is not defined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}