jest.config.js 3.4 KB

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