VITest - sgml/signature GitHub Wiki

Command Line

Use the following command to run vitest: npx vitest --config $VITEST_CONFIG ./tests/env-check.test.js

Config File

Use the following as a baseline config file for Vue:

import { defineConfig } from 'vitest/config';
import vue from '@vitejs/plugin-vue2'

export default defineConfig({
  plugins: [vue()],
  test: {
    globals: true,
    environment: 'node', // or 'node' based on your needs
    setupFiles: '/home/think/setupTests.ts', // adjust this if you have a setup file
    include: ['**/*.test.ts', '**/*.spec.js'],
  },
});

Boilerplate Sanity Test

Use the following tests to check parsers:

Vue

import { expect, test } from 'vitest'
import { mount } from '@vue/test-utils'
import MyComponent from './MyComponent.vue'

test('Vue2 parser works', async () => {
  const wrapper = mount(MyComponent)
  const h1 = wrapper.find('h1')
  expect(h1.text()).toBe('Hello, Vue2!')
})