Skip to content

Commit 3096146

Browse files
authored
Merge pull request #53232 from nextcloud/backport/52298/stable31
[stable31] test: ignore git-ignored files from tests
2 parents a113b5e + cf8376c commit 3096146

File tree

3 files changed

+58
-36
lines changed

3 files changed

+58
-36
lines changed

build/files-checker.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
'tsconfig.json',
8989
'vendor-bin',
9090
'version.php',
91-
'vitest.config.ts',
91+
'vitest.config.mts',
9292
'webpack.common.js',
9393
'webpack.config.js',
9494
'webpack.modules.js',

vitest.config.mts

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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+
})

vitest.config.ts

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)