explore-frontend / vscode-vitest-runner

Run your testcase by vitest.
https://marketplace.visualstudio.com/items?itemName=kingwl.vscode-vitest-runner
MIT License
23 stars 20 forks source link

Run(Vitest) link fails for tests under sub-folders ("No test files found") #7

Open n8allan opened 1 year ago

n8allan commented 1 year ago

My folder structure is like this:

/
  vite.config.js
  src/
    lib/
      tree/
        btree.test.ts

vite.config.js looks like this:

import { sveltekit } from '@sveltejs/kit/vite';

/** @type {import('vite').UserConfig} */
const config = {
    plugins: [sveltekit()],
    test: {
        include: ['src/**/*.{test,spec}.{js,ts}']
    }
};

export default config;

When I click on Run(Vitest) from btree.test.ts, the terminal includes a "cd" to the /src/lib/tree folder where npx... is ran. As a result, I get "No test files found". The error says the include is src/**/*.{test,spec}.{js,ts} so I assume that the problem is that relative to the path where the test file is, there is indeed no "src" sub-folder.

adamhill86 commented 1 year ago

I'm having the same issue.

vite.config.ts

import { sveltekit } from '@sveltejs/kit/vite';
import type { UserConfig } from 'vite';

const config: UserConfig = {
  plugins: [sveltekit()],
    test: {
      include: ['src/**/*.{test,spec}.{js,ts}']
    }
};

export default config;
rluvaton commented 1 year ago

This should fix it:

VanCoding commented 1 year ago

For me, it works when using absolute paths like this:

include: [__dirname+'/src/**/*.{test,spec}.{js,ts}']
rluvaton commented 1 year ago

forked and published my own package given this is not maintained https://marketplace.visualstudio.com/items?itemName=rluvaton.vscode-vitest