You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Which Vitest version fits this toolchain, and what replaces each Jest feature the suite uses #286
Which Vitest version works with Vite 8, electron-vite 6 and Node 22 under Yarn 1, and does it need its own config file or can it read electron.vite.config.js? For each Jest feature this suite uses, what is the Vitest replacement and where does behaviour differ: jest.fn, jest.spyOn, jest.mock (hoisting), jest.isolateModules, jest.restoreAllMocks, moduleNameMapper (electron, @sentry/electron/renderer, .css), setupFiles and setupFilesAfterEnv, transformIgnorePatterns for d3-array, the jsdom environment, and require() in 14 test files. Sources: jest.config.js, jest/, the Vitest docs and migration guide.
Version. Use vitest@^5.1.1 (npm latest). Its engines.node is ^22.12.0 || ^24.0.0 || >=26.0.0 and its vite peer is ^6.4.0 || ^7.0.0 || ^8.0.0, so it fits Node 22.18 (.nvmrc), Node 24 (CI) and Vite 8.3.7. vite is a required peer in v5 and Yarn does not install peers; it is already a direct dev dependency here. Add jsdom@^29.1.1: jsdom 30 and 31 need Node ^22.22.2, which .nvmrc 22.18.0 does not meet. Fallback is vitest@4.1.12.
Config file. Vitest cannot read electron.vite.config.js. It looks only for vitest.config.*, then vite.config.*, in the root. The electron-vite file exports { main, preload, renderer }, not one Vite config. A root vitest.config.* is needed; it copies the one filenamify alias from the renderer block.
Jest feature
Vitest replacement
Behaviour difference
Globals (it, expect, jest)
globals: true, or imports from vitest
Off by default. Global types need "types": ["vitest/globals"].
jest.fn (96)
vi.fn
None for this suite (mockReset differs; not used).
jest.spyOn (21)
vi.spyOn
None.
jest.restoreAllMocks (1)
vi.restoreAllMocks
Restores spyOn spies only. The one site is unaffected.
jest.mock (2)
vi.mock, top level only
Hoisted, but works only with import, not require. Factory returns every export; default needs a default key. Nested call throws in v5.
jest.isolateModules (4)
None: vi.resetModules() + await import()
Async. Clears the whole registry. Top-level imports are not re-evaluated.
Applies to import in the repo's own source only. Not to require, not inside node_modules.
moduleNameMapper.css
Nothing
CSS is replaced with an empty string by default.
setupFiles + setupFilesAfterEnv
test.setupFiles, one ordered list
Hooks are allowed there. Exports are ignored.
transform (babel-jest)
Nothing
Vite's Oxc handles ts, jsx, tsx. Babel goes.
transformIgnorePatterns (d3-array)
Nothing
node_modules is loaded by Node; d3-array is "type": "module".
testEnvironment: 'jsdom'
environment: 'jsdom' + jsdom package
Default is node. Node globals stay visible next to the DOM ones.
roots, testMatch
test.include
Scope it to src and e2e/helpers.
require() (14 files)
import / await import(); createRequire for true CommonJS
require exists but leaves Vite: no transform, no alias, no mocks, no TypeScript.
beforeEach( () => stubBridge() ) (2)
Wrap the body in braces
A returned value is treated as a teardown function.
Of the 14 require files: 5 must change (getActiveState, and the 4 isolateModules files), 5 work as they are, 4 (e2e/helpers) load CommonJS helpers that stay CommonJS.
Open risks for the spike
The electron alias does not reach electron-log and electron-store, which require( 'electron' ) themselves. src/main/updates.test.js is the first test that can show it.
clearMocks defaults to true in v5. Set clearMocks: false to match Jest.
jsdom jumps from 16 to 29.
jest/mobxActionWarning.js is a setup file and is also imported by a test; both must see one module instance.
Not verified that Oxc picks jsx: "react-jsx" and define-semantics class fields from tsconfig.json. If not, add @vitejs/plugin-react (already installed) to the Vitest config.
The map says 67 test files under src/; a count finds 62.
Activity
jtklein-agents commentedon Nov 22, 2026
Resolution
Full findings, with sources:
docs/research/vitest-fit.mdonresearch/vitest-fit. The branch is throwaway and is never merged. Nothing was installed or run.Version. Use
vitest@^5.1.1(npmlatest). Itsengines.nodeis^22.12.0 || ^24.0.0 || >=26.0.0and itsvitepeer is^6.4.0 || ^7.0.0 || ^8.0.0, so it fits Node 22.18 (.nvmrc), Node 24 (CI) and Vite 8.3.7.viteis a required peer in v5 and Yarn does not install peers; it is already a direct dev dependency here. Addjsdom@^29.1.1: jsdom 30 and 31 need Node^22.22.2, which.nvmrc22.18.0 does not meet. Fallback isvitest@4.1.12.Config file. Vitest cannot read
electron.vite.config.js. It looks only forvitest.config.*, thenvite.config.*, in the root. The electron-vite file exports{ main, preload, renderer }, not one Vite config. A rootvitest.config.*is needed; it copies the onefilenamifyalias from the renderer block.it,expect,jest)globals: true, or imports fromvitest"types": ["vitest/globals"].jest.fn(96)vi.fnmockResetdiffers; not used).jest.spyOn(21)vi.spyOnjest.restoreAllMocks(1)vi.restoreAllMocksspyOnspies only. The one site is unaffected.jest.mock(2)vi.mock, top level onlyimport, notrequire. Factory returns every export; default needs adefaultkey. Nested call throws in v5.jest.isolateModules(4)vi.resetModules()+await import()moduleNameMapperelectron,@sentry/electron/renderertest.aliasimportin the repo's own source only. Not torequire, not insidenode_modules.moduleNameMapper.csssetupFiles+setupFilesAfterEnvtest.setupFiles, one ordered listtransform(babel-jest)ts,jsx,tsx. Babel goes.transformIgnorePatterns(d3-array)node_modulesis loaded by Node;d3-arrayis"type": "module".testEnvironment: 'jsdom'environment: 'jsdom'+jsdompackagenode. Node globals stay visible next to the DOM ones.roots,testMatchtest.includesrcande2e/helpers.require()(14 files)import/await import();createRequirefor true CommonJSrequireexists but leaves Vite: no transform, no alias, no mocks, no TypeScript.beforeEach( () => stubBridge() )(2)Of the 14
requirefiles: 5 must change (getActiveState, and the 4isolateModulesfiles), 5 work as they are, 4 (e2e/helpers) load CommonJS helpers that stay CommonJS.Open risks for the spike
electronalias does not reachelectron-logandelectron-store, whichrequire( 'electron' )themselves.src/main/updates.test.jsis the first test that can show it.setImmediate.docs/agents/checks.mdsays React's scheduler then races jsdom teardown.clearMocksdefaults totruein v5. SetclearMocks: falseto match Jest.jest/mobxActionWarning.jsis a setup file and is also imported by a test; both must see one module instance.jsx: "react-jsx"and define-semantics class fields fromtsconfig.json. If not, add@vitejs/plugin-react(already installed) to the Vitest config.src/; a count finds 62.