jest.config.js 3.3 KB

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