vitest-dev / vitest-dev/vitest

Browser Mode: Electron support

Open
#5,883 2 comments 27 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feat: browser p2-nice-to-have
Dominant language
TypeScript
Stars
17.1k
Forks
2k
Avg merge
1d 22h
Merged PRs (30d)
94

Description

Clear and concise description of the problem

It would be great to have an Electron mode for browser mode so that Electron apps could be tested easily. Currently, to test code that needs to import electron (provided by the electron runtime here, I believe), my understanding is it's necessary to either mock electron or set up full E2E testing manually, outside of vitest.

I may be able to make a PR for this, with some guidance.

Suggested solution

Webdriverio and Playwright seem to have some kind of Electron support:

However I'm not sure if those play nicely with the model of browser mode.

Alternative

An alternative which would be very useful: to just allow testing the main Electron process code (not testing the renderer or preload code). It may be as easy as allowing to swap node:vm for the electron executable here in the vite-node runtime, since my understanding is the electron exec is just a wrapper around node with electron modules injected. It seems like there has been a lot of work put into vite-node, so it would be nice to reuse that instead of making an entirely new runner.

Additional context

Electron was mentioned in #1470 in the context of custom test runners, but I'm not sure if any work specific to electron was done.

This repo could be useful for making a new runner or modifying the existing: https://github.com/kayahr/jest-electron-runner

Validations

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the browser-mode context and the vite-node entry point at packages/vite-node/src/client.ts, especially the referenced runtime section. Compare the Electron approaches linked in the issue and define whether the goal is full browser-mode support or main-process testing; done requires a concrete scope and validated Electron test coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
electron, typescript
Domain
desktop-dev, testing
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.