Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows drive casing causes issues with mocking #5798

Closed
6 tasks done
dylanclaywell opened this issue May 30, 2024 · 1 comment · Fixed by #6779
Closed
6 tasks done

Windows drive casing causes issues with mocking #5798

dylanclaywell opened this issue May 30, 2024 · 1 comment · Fixed by #6779
Labels
p3-minor-bug An edge case that only affects very specific usage (priority) windows

Comments

@dylanclaywell
Copy link

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

@sheremet-va
Copy link
Member

sheremet-va commented Oct 25, 2024

#6779 fixes the issue, but this part now actually breaks the test runner:

    root: fileURLToPath(new URL('./', import.meta.url)),

This is a bug with Vite, we can't influence it in Vitest, but I will open a ticket there. Actually, this is an issue with Vitest: #6792

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p3-minor-bug An edge case that only affects very specific usage (priority) windows
Projects
None yet
3 participants