You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.7 KiB

  1. /**
  2. * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
  3. * SPDX-License-Identifier: CC0-1.0
  4. */
  5. import vue from '@vitejs/plugin-vue'
  6. import { exec } from 'node:child_process'
  7. import { resolve } from 'node:path'
  8. import { promisify } from 'node:util'
  9. import { defaultExclude, defineConfig } from 'vitest/config'
  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. export default defineConfig({
  26. plugins: [vue()],
  27. test: {
  28. include: ['build/frontend/apps/**/*.{test,spec}.?(c|m)[jt]s?(x)'],
  29. environment: 'jsdom',
  30. environmentOptions: {
  31. jsdom: {
  32. url: 'http://nextcloud.local',
  33. },
  34. },
  35. coverage: {
  36. include: ['build/frontend/apps/*/src/**', 'build/frontend/core/src/**'],
  37. exclude: ['**.spec.*', '**.test.*', '**.cy.*', 'core/src/tests/**'],
  38. provider: 'v8',
  39. reporter: ['lcov', 'text'],
  40. },
  41. setupFiles: [
  42. resolve(import.meta.dirname, '__tests__/mock-window.js'),
  43. resolve(import.meta.dirname, '__tests__/setup-testing-library.js'),
  44. ],
  45. exclude: [
  46. ...defaultExclude,
  47. ...gitIgnore,
  48. ],
  49. globalSetup: resolve(import.meta.dirname, '__tests__/setup-global.js'),
  50. server: {
  51. deps: {
  52. inline: [/@nextcloud\//],
  53. },
  54. },
  55. },
  56. })