Skip to content

webdriverio-community/wdio-vite-service

Repository files navigation

WebdriverIO loves Nuxt

WDIO Vite Service Tests

This service helps you to launch your application when using Vite as build tool. It automatically starts the Vite server using your vite.conf.js before launching the test.

Installation

If you are getting started with WebdriverIO you can use the configuration wizard to set everything up:

npm init wdio@latest .

It will install all necessary plugins for you. If you are adding this service on an existing setup, you can always install it via:

npm install wdio-vite-service --save-dev

Configuration

To enable the service, just add it to your services list in your wdio.conf.js file, e.g.:

// wdio.conf.js
export const config = {
    // ...
    services: ['vite'],
    // ...
};

You can apply service option by passing in an array with a config object, e.g.:

// wdio.conf.js
export const config = {
    // ...
    services: [
        ['vite', {
            configFile: './custom.vite.conf.js'
        }]
    ],
    // ...
};

Usage

If your config is set up accordingly, the service will set the baseUrl option to point to your application. You can navigate to it via the url command, e.g.:

await browser.url('/')
await expect(browser).toHaveTitle('Vite + Lit + TS')
await expect($('aria/Vite + Lit')).toBePresent()

Options

configFile

Path to config file.

Type: string
Default: vite.conf.ts

configRoot

Root directory of the project.

Type: string
Default: process.cwd()

mode

Define the mode used to start the server. See also Vite Modes.

Type: string
Default: development

logLevel

Adjust console output verbosity.

Type: 'info' | 'warn' | 'error' | 'silent'
Default: 'info'


For more information on WebdriverIO see the homepage.