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

Tests with special characters in the filename are not processed correctly #2731

Closed
6 tasks done
jonluca opened this issue Jan 22, 2023 · 7 comments
Closed
6 tasks done

Comments

@jonluca
Copy link

jonluca commented Jan 22, 2023

Describe the bug

I have a file in a directory called __({[ % & $ # @ ~ ,)}]__/special-characters.spec.ts`.

The full path to the test is

/Users/jonlucadecaro/Documents/Other/json-schema-ref-parser/test/specs/__({[ % & $ # @ ` ~ ,)}]__/special-characters.spec.ts

The error is

 FAIL  test/specs/__({[ % & $ # @ ` ~ ,)}]__/special-characters.spec.ts [ test/specs/__({[ % & $ # @ ` ~ ,)}]__/special-characters.spec.ts ]
Error: Failed to load url /Users/jonlucadecaro/Documents/Other/json-schema-ref-parser/test/specs/__({[ % & $ # @ ` ~ ,)}]__/special-characters.spec.ts (resolved id: /Users/jonlucadecaro/Documents/Other/json-schema-ref-parser/test/specs/__({[ % & $ # @ ` ~ ,)}]__/special-characters.spec.ts). Does the file exist?
 ❯ loadAndTransform node_modules/vite/dist/node/chunks/dep-5e7f419b.js:39304:21

Reproduction

Create a test spec in a file directory named:

__({[ % & $ # @ ` ~ ,)}]__/special-characters.spec.ts

Then try and run the test. The contents of the test do not matter.

System Info

System:
    OS: macOS 13.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 366.42 MB / 64.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 19.4.0 - /opt/homebrew/bin/node
    Yarn: 1.22.19 - ~/.yarn/bin/yarn
    npm: 9.2.0 - /opt/homebrew/bin/npm
  Browsers:
    Brave Browser: 109.1.47.171
    Chrome: 109.0.5414.87
    Firefox: 108.0.2
    Safari: 16.2
  npmPackages:
    vitest: ^0.27.2 => 0.27.2

Used Package Manager

yarn

Validations

@sheremet-va
Copy link
Member

This seems like a Vite error. Please, create an issue in their repository.

@jonluca
Copy link
Author

jonluca commented Jan 22, 2023

Sounds good, opened vitejs/vite#11784

@lucaspessivaldo
Copy link

lucaspessivaldo commented Jan 23, 2023

I think the problem is because the path there are spaces between the caracteres, ({[ % & $ # @ ~ ,)}], so that is a invalid path, you need to use backslash \ to scape the spaces.

@jonluca
Copy link
Author

jonluca commented Jan 23, 2023

I don't write the filename or path anywhere though - this is vitest auto-discovering it based on the test directory.

I can't change the name of the directory because the test is actually testing a program that reads special characters from that local directory.

@sheremet-va
Copy link
Member

I think the problem is because the path there are spaces between the caracteres, ({[ % & $ # @ ~ ,)}], so that is a invalid path, you need to use backslash \ to scape the spaces.

Vitest supports spaces in file path

@so1ve
Copy link
Contributor

so1ve commented May 1, 2023

Have you set any alias?

@sheremet-va
Copy link
Member

Vitest follows Vite rules, and unfortunately it cannot support some special characters: vitejs/vite#11784 (comment)

@sheremet-va sheremet-va closed this as not planned Won't fix, can't repro, duplicate, stale Feb 16, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Mar 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants