jest.config.js 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. rootDir: '.',
  18. roots: ['<rootDir>'],
  19. testMatch: ['<rootDir>/test/unit/**/*.test.ts', '<rootDir>/test/unit/**/*.test.js'],
  20. testEnvironment: 'node',
  21. // Automatically clear mock calls and instances between every test
  22. clearMocks: true,
  23. moduleNameMapper: MODULE_NAME_MAPPING,
  24. },
  25. {
  26. displayName: 'server',
  27. preset: 'ts-jest/presets/js-with-ts',
  28. rootDir: '.',
  29. roots: ['<rootDir>'],
  30. testMatch: ['<rootDir>/test/integration/**/*.test.ts', '<rootDir>/test/integration/**/*.test.js'],
  31. // https://regex101.com/r/jTaxYS/1
  32. modulePathIgnorePatterns: ['<rootDir>/test/integration/*.*/v5(..*)*.[t|j]s'],
  33. testEnvironment: 'node',
  34. globalSetup: '<rootDir>/test/integration/global-setup.js',
  35. globalTeardown: '<rootDir>/test/integration/global-teardown.js',
  36. setupFilesAfterEnv: ['<rootDir>/test/integration/setup.js'],
  37. // Automatically clear mock calls and instances between every test
  38. clearMocks: true,
  39. moduleNameMapper: MODULE_NAME_MAPPING,
  40. },
  41. {
  42. displayName: 'server-v5',
  43. preset: 'ts-jest/presets/js-with-ts',
  44. rootDir: '.',
  45. roots: ['<rootDir>'],
  46. testMatch: ['<rootDir>/test/integration/**/v5.*.test.ts', '<rootDir>/test/integration/**/v5.*.test.js'],
  47. testEnvironment: 'node',
  48. globalSetup: '<rootDir>/test/integration/global-setup.js',
  49. globalTeardown: '<rootDir>/test/integration/global-teardown.js',
  50. setupFilesAfterEnv: ['<rootDir>/test/integration/setup.js'],
  51. // Automatically clear mock calls and instances between every test
  52. clearMocks: true,
  53. moduleNameMapper: MODULE_NAME_MAPPING,
  54. },
  55. ],
  56. // Automatically clear mock calls and instances between every test
  57. clearMocks: true,
  58. // Indicates whether the coverage information should be collected while executing the test
  59. collectCoverage: true,
  60. // An array of glob patterns indicating a set of files for which coverage information should be collected
  61. // collectCoverageFrom: undefined,
  62. // The directory where Jest should output its coverage files
  63. coverageDirectory: 'coverage',
  64. // An array of regexp pattern strings used to skip coverage collection
  65. coveragePathIgnorePatterns: [
  66. 'index.ts',
  67. '/config/',
  68. '/resource/',
  69. '/node_modules/',
  70. ],
  71. };