|
| 1 | +/** |
| 2 | + * SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors |
| 3 | + * SPDX-License-Identifier: CC0-1.0 |
| 4 | + */ |
| 5 | +import { defaultExclude, defineConfig } from 'vitest/config' |
| 6 | +import vue from '@vitejs/plugin-vue2' |
| 7 | +import { exec } from 'node:child_process' |
| 8 | +import { promisify } from 'node:util' |
| 9 | + |
| 10 | +const gitIgnore: string[] = [] |
| 11 | +// get all files ignored in the apps directory (e.g. if putting `view` app there). |
| 12 | +try { |
| 13 | + const execAsync = promisify(exec) |
| 14 | + const { stdout } = await execAsync('git check-ignore apps/*', { cwd: __dirname }) |
| 15 | + gitIgnore.push(...stdout.split('\n').filter(Boolean)) |
| 16 | + // eslint-disable-next-line no-console |
| 17 | + console.log('Git ignored files excluded from tests: ', gitIgnore) |
| 18 | +} catch (error) { |
| 19 | + // we can ignore error code 1 as this just means there are no ignored files |
| 20 | + if (error.code !== 1) { |
| 21 | + // but otherwise something bad is happening and we should re-throw |
| 22 | + throw error |
| 23 | + } |
| 24 | +} |
| 25 | + |
| 26 | +export default defineConfig({ |
| 27 | + plugins: [vue()], |
| 28 | + test: { |
| 29 | + include: ['{apps,core}/**/*.{test,spec}.?(c|m)[jt]s?(x)'], |
| 30 | + environment: 'jsdom', |
| 31 | + environmentOptions: { |
| 32 | + jsdom: { |
| 33 | + url: 'http://nextcloud.local', |
| 34 | + }, |
| 35 | + }, |
| 36 | + coverage: { |
| 37 | + include: ['apps/*/src/**', 'core/src/**'], |
| 38 | + exclude: ['**.spec.*', '**.test.*', '**.cy.*', 'core/src/tests/**'], |
| 39 | + provider: 'v8', |
| 40 | + reporter: ['lcov', 'text'], |
| 41 | + }, |
| 42 | + setupFiles: [ |
| 43 | + '__tests__/mock-window.js', |
| 44 | + '__tests__/setup-testing-library.js', |
| 45 | + ], |
| 46 | + exclude: [ |
| 47 | + ...defaultExclude, |
| 48 | + ...gitIgnore, |
| 49 | + ], |
| 50 | + globalSetup: '__tests__/setup-global.js', |
| 51 | + server: { |
| 52 | + deps: { |
| 53 | + inline: [/@nextcloud\//], |
| 54 | + }, |
| 55 | + }, |
| 56 | + }, |
| 57 | +}) |
0 commit comments