jest.config.js 3.1 KB

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