Skip to content

Vitest extension doesn't run test files with tags #799

Description

@bennycode

Describe the bug

I am using tags in my unit tests and noticed that the Vitest extension for Visual Studio Code cannot run tests that are having tags declared.

Screenshot:

Image

Expected behavior

Tests are being executed.

Reproduction

Build a test case with tags, i.e.

describe('getResultOrThrow', () => {
  it('identifies an up-trending asset by a positive ROC', {tags: ['tulipindicators']}, () => {
    // ...  
  });
});

The extension cannot run the test although the tags are defined in the vites.config.ts file:

import { defineConfig, mergeConfig } from "vitest/config";
import baseConfig from "../../vitest.config.base";

export default mergeConfig(
  baseConfig,
  defineConfig({
    test: {
      tags: [
        {
          description: "...",
          name: "tulipindicators",
        },
      ],
    },
  }),
);

My vitest.config.base.ts file looks like this:

import {defineConfig} from 'vitest/config';

export default defineConfig({
  esbuild: {
    /*
     * Allows using the "accessor" keyword in TypeScript:
     * https://github.com/vitest-dev/vitest/issues/5976#issuecomment-2190804966
     */
    target: 'es2022',
  },
  test: {
    bail: 1,
    coverage: {
      exclude: ['src/start/**'],
      include: ['src/**'],
      provider: 'v8',
      reporter: ['html', 'lcov', 'text'],
    },
    environment: 'node',
    globals: true,
    // https://main.vitest.dev/guide/learn/writing-tests-with-ai.html#mock-cleanup
    restoreMocks: true,
    sequence: {
      concurrent: true,
      shuffle: true,
    },
  },
});

Output

> Error: The Vitest config does't define any "tags", cannot apply "tulipindicators" tag for this test. See: https://vitest.dev/guide/test-tags

Extension Version

1.50.8

Vitest Version

4.1.10

Validations

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions