location of results.json when use test.root in vite.config.ts
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
- [X] Follow our Code of Conduct
- [X] Read the Contributing Guidelines.
- [X] Read the docs.
- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- [X] Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- [X] The provided reproduction is a minimal reproducible example of the bug.
@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
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.