aboutsummaryrefslogtreecommitdiffstats
path: root/vitest.config.js
blob: 169a783fdda5b08bf06f6c9583802344137eeb46 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import {defineConfig} from 'vitest/dist/config.js';
import {readFile} from 'node:fs/promises';
import {dataToEsm} from '@rollup/pluginutils';
import {extname} from 'node:path';
import vue from '@vitejs/plugin-vue';

function stringPlugin() {
  return {
    name: 'string-plugin',
    enforce: 'pre',
    async load(id) {
      const path = id.split('?')[0];
      if (extname(path) !== '.svg') return null;
      return dataToEsm(await readFile(path, 'utf8'));
    }
  };
}

export default defineConfig({
  test: {
    include: ['web_src/**/*.test.js'],
    setupFiles: ['./web_src/js/test/setup.js'],
    environment: 'jsdom',
    testTimeout: 20000,
    open: false,
    allowOnly: true,
    passWithNoTests: true,
    watch: false,
    outputDiffLines: Infinity,
  },
  plugins: [
    stringPlugin(),
    vue(),
  ],
});