Skip to main content

Nuxt Service Service

wdio-nuxt-service is a 3rd party package, for more information please see GitHub | npm

This service helps you to launch your application when using Nuxt as build tool. It automatically starts the Nuxt server using your nuxt.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 detect your project as a Nuxt project and 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-nuxt-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: ['nuxt'],
// ...
};

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

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

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('Welcome to Nuxt!')
await expect($('aria/Welcome to Nuxt!')).toBePresent()

Options

rootDir

Root directory of the project.

Type: string
Default: process.cwd()

dotenv

Environment file to be loaded before the server starts.

Type: string
Default: .env

hostname

Hostname to start the server on.

Type: string
Default: localhost

port

Port to start the server on.

Type: number
Default: process.env.NUXT_PORT || config.devServer.port

https

Set to true if test server should be started on https (certificates need to be configured in Nuxt config).

Type: boolean
Default: false

sslCert

SSL certificate to be used for starting the server on https.

Type: string

sslKey

SSL key to be used for starting the server on https.

Type: string


For more information on WebdriverIO see the homepage.

Welcome! How can I help?

WebdriverIO AI Copilot