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

location of results.json when use test.root in vite.config.ts #3272

Closed
6 tasks done
tung1404 opened this issue Apr 29, 2023 · 2 comments · Fixed by #5229
Closed
6 tasks done

location of results.json when use test.root in vite.config.ts #3272

tung1404 opened this issue Apr 29, 2023 · 2 comments · Fixed by #5229
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)

Comments

@tung1404
Copy link

Describe the bug

Hi,

When I setup vite.config.ts as below, vitest will output the result to root_project\src\node_modules\.vitest\results.json
I think its location is root_project\node_modules\.vitest\results.json

/// <reference types="vitest" />
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';

// https://vitejs.dev/config/
export default defineConfig({
  define: {
    'import.meta.vitest': 'undefined',
  },
  plugins: [react()],
  test: {
    root: 'src',
    globals: true,
    environment: 'happy-dom',
    setupFiles: ['./test-setup.ts'],
    includeSource: ['**/*.{ts,tsx}'],
    mockReset: true,
    restoreMocks: true,
    css: true,
  },
});

Reproduction

{"version":"0.30.1","results":[[":src/App.test.tsx",{"duration":25,"failed":false}]]}

System Info

node 14
npm 6.14

Used Package Manager

npm

Validations

@lyx-jay
Copy link
Contributor

lyx-jay commented May 13, 2023

@sheremet-va
Hi, I find test: {root: } option cause this problem.
if your test files are in the src/abc/folder, then you set as below:

export default defineConfig({
  test: {
    root: './src/abc',
  }
});

vitest will output the result to src\abc\node_modules\.vitest\result.json.
I want to know what is the correct output path? I plan to fix this problem

@sheremet-va
Copy link
Member

sheremet-va commented May 17, 2023

I think we should deprecate cache.dir option and just use Vite's cacheDir. This way we don't need to resolve the cache filepath ourselves.

dev2820 added a commit to ganada-labs/nlog-BE that referenced this issue Jul 29, 2023
ref)
vitest-dev/vitest#3272

테스트 수행시 자동으로 utils/__tests__/ 등의 폴더에
node_modules/result.json 파일이 생성되는 현상이 있어 그 결과를 ./ 에만
저장하도록 수정했습니다.
@sheremet-va sheremet-va added p3-minor-bug An edge case that only affects very specific usage (priority) and removed bug pr welcome labels Feb 16, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Mar 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants