-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
Describe the bug
This issue started happening with Vite 6.3.x and PR #7846 doesn't seem to fix the issue I'm having in the Lerna-Lite project. all I could where these 2 Vite issues
- change in export behaviour need to be made since 6.3.* release vitejs/vite#19898
- Export overrides broken in tests with Vite 6.3.0+ vitejs/vite#19915
but that seems totally unrelated to my issue. In my project Lerna-Lite, I'm only using Vitest because it's a Node app and Vite is only installed indirectly and for now I have to stay with Vite 6.2.x to avoid the failures.
My failure and repro are in this GitHub Actions workflow
https://github.com/lerna-lite/lerna-lite/actions/runs/14698826781/job/41244615531
and the PR (that I now closed to avoid failures in the project)
lerna-lite/lerna-lite#1024
Also note that my project is also included in the vitest-ecosystem-ci but probably doesn't fail yet because it probably does not use the latest Vite version (because again my project is a Node app)
I get these failures only when using Vite 6.3.x, while previous 6.2.x is all good. I haven't had a chance to really dig into the problem, I just decided to stay on previous Vite for now. Should I open a new Vitest issue?
⎯⎯⎯⎯⎯⎯ Failed Suites 6 ⎯⎯⎯⎯⎯⎯⎯
FAIL packages/publish/src/__tests__/publish-from-git.spec.ts [ packages/publish/src/__tests__/publish-from-git.spec.ts ]
Error: [vitest] There was an error when mocking a module. If you are using "vi.mock" factory, make sure there are no top level variables inside, since this call is hoisted to top of the file. Read more: https://vitest.dev/api/vi.html#vi-mock
❯ packages/publish/src/__tests__/publish-from-git.spec.ts:35:1
33| import { npmPublish } from '../lib/npm-publish.js';
34| import { npmPublish as npmPublishMock } from '../lib/__mocks__/npm-pub…
35| import { logOutput, promptConfirmation, PublishCommandOption, throwIfU…
| ^
36|
37| // helpers
Caused by: Error: [vitest] There was an error when mocking a module. If you are using "vi.mock" factory, make sure there are no top level variables inside, since this call is hoisted to top of the file. Read more: https://vitest.dev/api/vi.html#vi-mock
❯ packages/core/src/filter-packages/lib/filter-packages.ts:2:1
Caused by: ReferenceError: Cannot access 'Command' before initialization
❯ Module.get [as Command] packages/core/src/command.ts:1:103
❯ packages/publish/src/__tests__/publish-from-git.spec.ts:14:70
❯ packages/core/src/filter-packages/lib/filter-packages.ts:2:1Reproduction
Lerna-Lite commit 450ce5c
Clone the Lerna-Lite project and git checkout the Renovate commit 450ce5c
git clone https://github.com/lerna-lite/lerna-lite
git checkout 450ce5cdThen open any of the 7 failing unit test spec file and use VSCode debugger with the "Vitest debug current file" to debug them, any of these tests fail:
- packages/publish/src/tests/publish-from-git.spec.ts:35:1
- packages/publish/src/tests/publish-from-package.spec.ts:42:1
- packages/publish/src/tests/publish-lifecycle-scripts.spec.ts:42:1
- packages/version/src/tests/version-command.spec.ts:42:1
- packages/version/src/tests/version-conventional-commits.spec.ts:45:1
- packages/version/src/tests/version-lifecycle-scripts.spec.ts:23:1
- packages/version/src/conventional-commits/tests/conventional-commits.spec.ts:282:7
System Info
System:
OS: Windows 11 10.0.22631
CPU: (12) x64 Intel(R) Xeon(R) CPU E5-1650 v2 @ 3.50GHz
Memory: 17.62 GB / 31.93 GB
Binaries:
Node: 20.19.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.19 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 10.9.0 - C:\Program Files\nodejs\npm.CMD
pnpm: 9.15.4 - ~\AppData\Local\pnpm\pnpm.CMD
Browsers:
Chrome: 135.0.7049.115
Edge: Chromium (128.0.2739.42)
Internet Explorer: 11.0.22621.3527Used Package Manager
npm
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status