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

globalSetup script is executed with wrong CWD #503

Closed
4 tasks done
maxpatiiuk opened this issue Oct 14, 2024 · 2 comments
Closed
4 tasks done

globalSetup script is executed with wrong CWD #503

maxpatiiuk opened this issue Oct 14, 2024 · 2 comments

Comments

@maxpatiiuk
Copy link

Describe the bug

When using vitest.workspace.ts file in a monorepo, the globalSetup script is executed with the CWD set to the monorepo root rather than the package root.

The vite.config.ts is correctly executed with the package root as CWD.

Reproduction

Reproduction repository: https://github.com/maxpatiiuk/vitest-wrong-dir

  1. Clone the repository

    git clone https://github.com/maxpatiiuk/vitest-wrong-cwd
    cd vite-wrong-cwd
  2. Install dependencies

    npm install
  3. In VS Code with the "Vitest" extension installed, open the packages/calcite-components/src/utils/component.spec.ts file from this repository.

  4. Open the "Output -> Vitest" panel in VS Code to see the log output for the "Vitest" extension. See that the globalSetup script is executed with the CWD set to the monorepo root rather than package root.

Output

[INFO 7:25:38 PM] [v1.6.0] Vitest extension is activated because Vitest is installed or there is a Vite/Vitest config file in the workspace.
[INFO 7:25:38 PM] [API] Running Vitest v2.1.2 (vitest-wrong-cwd/vitest.workspace.ts) with [email protected]: /Users/mak13180/.nvm/versions/node/v20.16.0/bin/node
[INFO 7:25:38 PM] [Worker] 🟥 vite.config.ts cwd: /Users/mak13180/site/esri/vitest-wrong-cwd/packages/calcite-components
[INFO 7:25:38 PM] [API] Vitest v2.1.2 (vitest-wrong-cwd/vitest.workspace.ts) child process 45982 created
[INFO 7:25:38 PM] [VSCODE] Watching vitest-wrong-cwd with pattern **/*
[INFO 7:25:45 PM] [API] Collecting tests: packages/calcite-components/src/utils/component.spec.ts
[INFO 7:25:45 PM] [Worker] 🟥 globalSetup.ts cwd: /Users/mak13180/site/esri/vitest-wrong-cwd

Version

v1.6.0

Validations

@sheremet-va
Copy link
Member

I don't think this is related to the extension. Can you reproduce the same behaviour by running vitest in the root?

@maxpatiiuk
Copy link
Author

You are right - I was able to reproduce by directly calling npx vitest from the monorepo root.
I didn't know you can call vitest like that.

Opened an issue in vitest: vitest-dev/vitest#6706. Will close this issue

@maxpatiiuk maxpatiiuk closed this as not planned Won't fix, can't repro, duplicate, stale Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants