-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Labels
Description
Describe the bug
After upgrading from 2.0.4 to 2.0.5 our tests which rely on module mocking via the __mocks__
folder are now failing with:
Error: ENOENT: no such file or directory, stat '/myproject/__mocks__/index.ts'
Reproduction
To reproduce this, you'll need:
- A
__mocks__
folder with the following structure:__mocks__
/archiver
/index.ts
/ora
/index.ts
- A test which uses one of the mocked modules (in this case
archiver
orora
) and callsvi.mock('ora')
It seems like (maybe after #6204) Vitest now expects the __mocks__
folder to have an index.*
file, whereas before it wasn't needed.
For a StackBlitz repro see: https://stackblitz.com/edit/vitest-dev-vitest-snzivu?file=package.json,test%2Fbasic.test.ts,src%2Fbasic.ts&initialPath=__vitest__/. Run npm run test
to reproduce.
System Info
System:
OS: macOS 14.6
CPU: (12) arm64 Apple M2 Max
Memory: 1.99 GB / 32.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.16.0 - ~/.nvm/versions/node/v20.16.0/bin/node
Yarn: 1.22.19 - ~/.nvm/versions/node/v20.16.0/bin/yarn
npm: 10.8.1 - ~/.nvm/versions/node/v20.16.0/bin/npm
Browsers:
Chrome: 127.0.6533.89
Chrome Canary: 129.0.6631.0
Safari: 17.6
Used Package Manager
yarn
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.