WDIO Vite Service

raw JSON →
2.1.1 verified Mon Apr 27 auth: no javascript

WebdriverIO service that automatically starts a Vite dev server before tests and sets the baseUrl to point to the application. Version 2.1.1 supports WebdriverIO v9 and Node.js >=18. It integrates seamlessly with Vite-based frameworks like Remix and provides options for custom config file, root directory, mode, and log level. The service is actively maintained with a release cadence of several releases per year, and it ships TypeScript definitions.

error Error: Cannot find module 'wdio-vite-service'
cause Package not installed or not in node_modules
fix
Run npm install wdio-vite-service --save-dev or pnpm add -D wdio-vite-service
error TypeError: services[0] is not iterable
cause Service configured incorrectly (e.g., using { } instead of ['vite', options])
fix
Use array syntax: services: [['vite', { configFile: './vite.config.ts' }]]
error Error: Failed to start Vite server
cause Vite config file not found or invalid
fix
Ensure the path in configFile option is correct and the file exports a valid Vite config.
breaking Version 2.0.0 drops support for Node.js <18. You must upgrade Node.js to v18+.
fix Update Node.js to version 18 or higher.
breaking Version 2.0.0 supports only WebdriverIO v9. Remove compatibility with WDIO v8.
fix Upgrade WebdriverIO to version 9 or later.
deprecated Using CommonJS require() to load the service is discouraged; ESM is recommended.
fix Use ESM imports (e.g., import ViteService from 'wdio-vite-service') or use string 'vite' in services list.
gotcha The service sets baseUrl automatically. If you override baseUrl in config, your override might be clobbered.
fix Do not set baseUrl manually when using the vite service; let the service manage it.
npm install wdio-vite-service
yarn add wdio-vite-service
pnpm add wdio-vite-service

Registers the vite service with custom config, then uses the baseUrl to navigate and assert in tests.

// wdio.conf.js
import { config } from '@wdio/types';

export const config: config.Testrunner = {
  // ...
  services: [
    ['vite', {
      configFile: './vite.config.ts',
      configRoot: process.cwd(),
      mode: 'development',
      logLevel: 'info'
    }]
  ],
  // ...
};

// In a test file (e.g., test.e2e.ts):
await browser.url('/');
await expect(browser).toHaveTitle('My App');
await expect($('aria/Login')).toBePresent();