jest.config.js 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. // For a detailed explanation regarding each configuration property, visit:
  2. // https://jestjs.io/docs/en/configuration.html
  3. // https://kulshekhar.github.io/ts-jest/user/config/
  4. const MODULE_NAME_MAPPING = {
  5. '^\\^/(.+)$': '<rootDir>/$1',
  6. '^~/(.+)$': '<rootDir>/src/$1',
  7. '^@growi/(.+)$': '<rootDir>/../$1/src',
  8. };
  9. module.exports = {
  10. // Indicates whether each individual test should be reported during the run
  11. verbose: true,
  12. preset: 'ts-jest/presets/js-with-ts',
  13. projects: [
  14. {
  15. displayName: 'unit',
  16. preset: 'ts-jest/presets/js-with-ts',
  17. // transform ESM to CJS
  18. transformIgnorePatterns: [
  19. '/node_modules/(?!remark-gfm)/',
  20. ],
  21. rootDir: '.',
  22. roots: ['<rootDir>'],
  23. testMatch: ['<rootDir>/test/unit/**/*.test.ts', '<rootDir>/test/unit/**/*.test.js'],
  24. testEnvironment: 'node',
  25. // Automatically clear mock calls and instances between every test
  26. clearMocks: true,
  27. moduleNameMapper: MODULE_NAME_MAPPING,
  28. },
  29. {
  30. displayName: 'server',
  31. preset: 'ts-jest/presets/js-with-ts',
  32. rootDir: '.',
  33. roots: ['<rootDir>'],
  34. testMatch: ['<rootDir>/test/integration/**/*.test.ts', '<rootDir>/test/integration/**/*.test.js'],
  35. // https://regex101.com/r/jTaxYS/1
  36. modulePathIgnorePatterns: ['<rootDir>/test/integration/*.*/v5(..*)*.[t|j]s'],
  37. testEnvironment: 'node',
  38. globalSetup: '<rootDir>/test/integration/global-setup.js',
  39. globalTeardown: '<rootDir>/test/integration/global-teardown.js',
  40. setupFilesAfterEnv: ['<rootDir>/test/integration/setup.js'],
  41. // Automatically clear mock calls and instances between every test
  42. clearMocks: true,
  43. moduleNameMapper: MODULE_NAME_MAPPING,
  44. },
  45. {
  46. displayName: 'server-v5',
  47. preset: 'ts-jest/presets/js-with-ts',
  48. rootDir: '.',
  49. roots: ['<rootDir>'],
  50. testMatch: ['<rootDir>/test/integration/**/v5.*.test.ts', '<rootDir>/test/integration/**/v5.*.test.js'],
  51. testEnvironment: 'node',
  52. globalSetup: '<rootDir>/test/integration/global-setup.js',
  53. globalTeardown: '<rootDir>/test/integration/global-teardown.js',
  54. setupFilesAfterEnv: ['<rootDir>/test/integration/setup.js'],
  55. // Automatically clear mock calls and instances between every test
  56. clearMocks: true,
  57. moduleNameMapper: MODULE_NAME_MAPPING,
  58. },
  59. ],
  60. // Automatically clear mock calls and instances between every test
  61. clearMocks: true,
  62. // Indicates whether the coverage information should be collected while executing the test
  63. collectCoverage: true,
  64. // An array of glob patterns indicating a set of files for which coverage information should be collected
  65. // collectCoverageFrom: undefined,
  66. // The directory where Jest should output its coverage files
  67. coverageDirectory: 'coverage',
  68. // An array of regexp pattern strings used to skip coverage collection
  69. coveragePathIgnorePatterns: [
  70. 'index.ts',
  71. '/config/',
  72. '/resource/',
  73. '/node_modules/',
  74. ],
  75. };