Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

Repository files navigation

@lambdatest/vitest

Runs Vitest browser mode on the LambdaTest grid. Vitest stays on your machine; the browsers run on LambdaTest and load the test page through a tunnel the package starts for you.

Setup

npm i -D @lambdatest/vitest
export LT_USERNAME=... LT_ACCESS_KEY=...

In vitest.config.ts, use lambdatest() where you had playwright():

import { defineConfig } from 'vitest/config'
import { lambdatest } from '@lambdatest/vitest'

export default defineConfig({
  test: {
    browser: {
      enabled: true,
      provider: lambdatest(),
      instances: [{ browser: 'chromium' }],
    },
  },
})

Then run npx vitest run as before. Needs Node 22.12 or newer, Vitest 4.1 or newer, and @vitest/browser-playwright.

What the package does

  • Points Vitest's Playwright provider at the LambdaTest Playwright endpoint, with the capabilities built from the options.
  • Starts a LambdaTest tunnel before the first browser opens and stops it when Vitest closes. The tunnel binary is downloaded once to ~/.lambdatest/v3, the same place @lambdatest/node-tunnel keeps it; LT_TUNNEL_BIN points at one of your own.
  • Opens the test page as localhost.lambdatest.com (127.0.0.1), as Safari and WebKit send localhost straight to the cloud machine instead of through the tunnel.
  • Marks each session passed or failed before its browser closes, with an "N passed, M failed" remark.
  • Runs the cloud browsers in Vitest's headless mode, so Vitest can close a finished browser to free a parallel session, and gives a session up to 300 s to leave the grid's queue.

Options

Option Default
platform Windows 11 Such as macOS Tahoe
browserVersion latest
browserName from the instance The LambdaTest browser, such as MicrosoftEdge for a chromium instance
build the folder name
name the instance name The session name
tunnelName none A tunnel you already run; the package then starts none
ltOptions Any other LT:Options capability, such as video or resolution
via playwright selenium runs through the Selenium hub with Vitest's WebdriverIO provider (install @vitest/browser-webdriverio)

Vitest's browser names map to LambdaTest's: chromium to Chrome, firefox to pw-firefox, webkit to pw-webkit. Each instance can take its own provider, for another browser or platform:

instances: [
  { browser: 'chromium' },
  { browser: 'chromium', name: 'edge', provider: lambdatest({ browserName: 'MicrosoftEdge' }) },
  { browser: 'webkit', provider: lambdatest({ platform: 'macOS Tahoe' }) },
],

More browsers than parallel sessions

Vitest opens up to maxWorkers browsers at once. When a run has more instances than your plan's parallel sessions, set maxWorkers to your parallel sessions, so Vitest closes a finished browser before it opens the next one.

Known limits

  • WebKit on Windows loads the test page but cannot open its WebSocket back through the tunnel; use WebKit on macOS.
  • On the Selenium route, browsers stay headed, so keep the instances within your parallel sessions.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages