Skip to content

Windows drive casing causes issues with mocking #5798

@dylanclaywell

Description

@dylanclaywell

Describe the bug

When using manual mocks, the mock doesn't seem to work when vitest is run on a lowercase drive (i.e. running on c:\ vs C:).

This seems to be related to #5251, but I'm opening this as a separate issue since I think it relates to a different part of the code.

Reproduction

Using an example repository I created for this example: https://github.com/dylanclaywell/lowercase-test

NOTE: Make sure to run these steps on a Windows machine in a command prompt. Command prompt recommended because depending on the version of Powershell, Powershell might normalize the directory name including the drive letter, which results in not being able to reproduce this issue.

  1. Clone this repository anywhere on your local machine

  2. Navigate to the directory this project was cloned on, making sure to use an absolute path that contains the lowercase c:/ drive letter.
    For example:

    cd c:/<repo path>
  3. Run npm install

  4. Run npm run test

  5. Note the failing test (I have the test setup to expect a specific mocked value)

  6. Navigate to this same directory, making sure to use an absolute path that contains the uppercase c:/ drive letter.
    For example:

    cd C:/<repo path>
  7. Run npm run test again

  8. Note the succeeding test (the mocked value is returned in this case, so the test passes)

System Info

System:
  OS: Windows 11 10.0.22621
  CPU: (16) x64 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz
  Memory: 34.51 GB / 63.20 GB
Binaries:
  Node: 18.17.1 - C:\Program Files\nodejs\node.EXE
  npm: 9.6.7 - C:\Program Files\nodejs\npm.CMD
Browsers:
  Edge: Chromium (123.0.2420.97)
  Internet Explorer: 11.0.22621.3527

Used Package Manager

npm

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    os: windowsp3-minor-bugAn edge case that only affects very specific usage (priority)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions