jest.config.ts 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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: ['<rootDir>/__tests__/jest-setup.ts'],
  39. testEnvironment: 'jest-environment-jsdom',
  40. preset: 'ts-jest/presets/js-with-ts',
  41. roots: [
  42. '<rootDir>/__mocks__',
  43. '<rootDir>/__tests__',
  44. '<rootDir>/apps',
  45. '<rootDir>/core',
  46. ],
  47. transform: {
  48. // process `*.js` files with `babel-jest`
  49. '^.+\\.c?js$': 'babel-jest',
  50. '^.+\\.vue$': '@vue/vue2-jest',
  51. '^.+\\.ts$': ['ts-jest', {
  52. // @see https://github.com/kulshekhar/ts-jest/issues/4081
  53. tsconfig: './__tests__/tsconfig.json',
  54. }],
  55. },
  56. transformIgnorePatterns: [
  57. 'node_modules/(?!(' + ignorePatterns.join('|') + ')/)',
  58. ],
  59. // Allow mocking svg files
  60. moduleNameMapper: {
  61. '^.+\\.svg(\\?raw)?$': '<rootDir>/__mocks__/svg.js',
  62. '\\.s?css$': '<rootDir>/__mocks__/css.js',
  63. },
  64. modulePathIgnorePatterns: [
  65. '<rootDir>/apps2/',
  66. '<rootDir>/apps-extra/',
  67. ],
  68. }
  69. export default config