jest.config.ts 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /**
  2. * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
  3. * SPDX-License-Identifier: AGPL-3.0-or-later
  4. */
  5. import type { Config } from 'jest'
  6. // TODO: find a way to consolidate this in one place, with webpack.common.js
  7. const ignorePatterns = [
  8. '@buttercup/fetch',
  9. '@juliushaertl',
  10. '@mdi/svg',
  11. '@nextcloud/files',
  12. '@nextcloud/upload',
  13. '@nextcloud/vue',
  14. 'ansi-regex',
  15. 'camelcase',
  16. 'char-regex',
  17. 'hot-patcher',
  18. 'is-svg',
  19. 'layerr',
  20. 'mime',
  21. 'p-cancelable',
  22. 'p-limit',
  23. 'p-queue',
  24. 'p-timeout',
  25. 'splitpanes',
  26. 'string-length',
  27. 'strip-ansi',
  28. 'tributejs',
  29. 'unist-.+',
  30. 'url-join',
  31. 'vue-material-design-icons',
  32. 'webdav',
  33. 'yocto-queue',
  34. ]
  35. const config: Config = {
  36. testMatch: ['<rootDir>/**/*.(spec|test).(ts|js)'],
  37. clearMocks: true,
  38. setupFilesAfterEnv: [
  39. '<rootDir>/__tests__/jest-setup.ts',
  40. '<rootDir>/__tests__/mock-window.js',
  41. ],
  42. testEnvironment: 'jest-environment-jsdom',
  43. preset: 'ts-jest/presets/js-with-ts',
  44. roots: [
  45. '<rootDir>/__mocks__',
  46. '<rootDir>/__tests__',
  47. '<rootDir>/apps',
  48. '<rootDir>/core',
  49. ],
  50. transform: {
  51. // process `*.js` files with `babel-jest`
  52. '^.+\\.c?js$': 'babel-jest',
  53. '^.+\\.vue$': '@vue/vue2-jest',
  54. '^.+\\.ts$': ['ts-jest', {
  55. // @see https://github.com/kulshekhar/ts-jest/issues/4081
  56. tsconfig: './__tests__/tsconfig.json',
  57. }],
  58. },
  59. transformIgnorePatterns: [
  60. 'node_modules/(?!(' + ignorePatterns.join('|') + ')/)',
  61. ],
  62. // Allow mocking svg files
  63. moduleNameMapper: {
  64. '^.+\\.svg(\\?raw)?$': '<rootDir>/__mocks__/svg.js',
  65. '\\.s?css$': '<rootDir>/__mocks__/css.js',
  66. },
  67. modulePathIgnorePatterns: [
  68. '<rootDir>/apps2/',
  69. '<rootDir>/apps-extra/',
  70. ],
  71. }
  72. export default config