Skip to content

vitest - results.json gets created in ./src/node_modules #221

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

Closed
Bisdow opened this issue Jan 10, 2023 · 1 comment · Fixed by #227
Closed

vitest - results.json gets created in ./src/node_modules #221

Bisdow opened this issue Jan 10, 2023 · 1 comment · Fixed by #227

Comments

@Bisdow
Copy link

Bisdow commented Jan 10, 2023

Problem:

I created today a new project with create-vue and when directly afterwards run test:unit it creates under "./src" a folder "node_modules/.vitest" and puts the results.json there.
Also the coverage folder is created below ."/src" if i run tests with activated coverage.

I would expect that the files created by running unit tests are directly at the project root folder "./".

Problem reproduction

For reproduction:
I am working in a Windows WSL environment (Debian) and am using node 16.13.2.
I called npm init vue@latest
Then choose to use
[X] TypeSCript
[ ]No JSX
[X] Router
[X] Pinia
[X] Vitest
[X] E2E = Cypress
[X] ESLINT
[X] Prettier

I switched into the created project folder, run npm install and then npm run unit:test.
And then the folder/file gets created under "./src".
Also the coverage folder is created below ."/src" if i run tests with activated coverage.

Possible Reason:

In the package.json the script is
"test:unit": "vitest --environment jsdom --root src/",``
Which makes "./src" the root.

Eventual solution

Instead change the options to:
"test:unit": "vitest --environment jsdom --root ./ --dir ./src",``

Or perhaps directly move the root setting directly into the vite.config.ts file.
test: {
root: fileURLToPath(new URL('./', import.meta.url)),
},

@pinguet62
Copy link

pinguet62 commented Feb 4, 2023

Hello 👋
Same issue.
Probably from this PR: https://github.com/vuejs/create-vue/pull/76/files#diff-a2d6cfd9e15b7bdf0a232064fac6c8bae3d1626a3de6dd211dae1569cd661187
Restored default beevior by removing "--root src/"

haoqunjiang pushed a commit that referenced this issue Feb 23, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Co-authored-by: Haoqun Jiang <[email protected]>

Fixes #221 
Fixes #199
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants