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.

57 lines
1.6 KiB

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