vitest icon indicating copy to clipboard operation
vitest copied to clipboard

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

Open tung1404 opened this issue 2 years ago • 2 comments

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

tung1404 avatar Apr 29 '23 09:04 tung1404

@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

lyx-jay avatar May 13 '23 01:05 lyx-jay

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.

sheremet-va avatar May 17 '23 07:05 sheremet-va