jest.config.ts 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /**
  2. * @copyright Copyright (c) 2020 Marco Ambrosini <marcoambrosini@pm.me>
  3. *
  4. * @author Marco Ambrosini <marcoambrosini@pm.me>
  5. *
  6. * @license GNU AGPL version 3 or any later version
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU Affero General Public License as
  10. * published by the Free Software Foundation, either version 3 of the
  11. * License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU Affero General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. import type { Config } from 'jest'
  23. // TODO: find a way to consolidate this in one place, with webpack.common.js
  24. const ignorePatterns = [
  25. '@juliushaertl',
  26. '@mdi/svg',
  27. '@nextcloud/vue',
  28. 'ansi-regex',
  29. 'char-regex',
  30. 'is-svg',
  31. 'splitpanes',
  32. 'string-length',
  33. 'strip-ansi',
  34. 'tributejs',
  35. 'vue-material-design-icons',
  36. ]
  37. const config: Config = {
  38. testMatch: ['<rootDir>/**/*.(spec|test).(ts|js)'],
  39. clearMocks: true,
  40. setupFilesAfterEnv: ['<rootDir>/__tests__/jest-setup.ts'],
  41. testEnvironment: 'jest-environment-jsdom',
  42. preset: 'ts-jest/presets/js-with-ts',
  43. roots: [
  44. '<rootDir>/__mocks__',
  45. '<rootDir>/__tests__',
  46. '<rootDir>/apps',
  47. '<rootDir>/core',
  48. ],
  49. transform: {
  50. // process `*.js` files with `babel-jest`
  51. '^.+\\.js$': 'babel-jest',
  52. '^.+\\.vue$': '@vue/vue2-jest',
  53. '^.+\\.ts$': ['ts-jest', {
  54. // @see https://github.com/kulshekhar/ts-jest/issues/4081
  55. tsconfig: './__tests__/tsconfig.json',
  56. }],
  57. },
  58. transformIgnorePatterns: [
  59. 'node_modules/(?!(' + ignorePatterns.join('|') + ')/)',
  60. ],
  61. // Allow mocking svg files
  62. moduleNameMapper: {
  63. '^.+\\.svg(\\?raw)?$': '<rootDir>/__mocks__/svg.js',
  64. },
  65. modulePathIgnorePatterns: [
  66. '<rootDir>/apps2/',
  67. '<rootDir>/apps-extra/',
  68. ],
  69. }
  70. export default config