jest.config.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. };
  7. module.exports = {
  8. // Indicates whether each individual test should be reported during the run
  9. verbose: true,
  10. moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
  11. projects: [
  12. {
  13. displayName: 'unit',
  14. transform: {
  15. '^.+\\.(t|j)sx?$': '@swc/jest',
  16. },
  17. // transform ESM to CJS (includes all packages in node_modules)
  18. transformIgnorePatterns: [],
  19. rootDir: '.',
  20. roots: ['<rootDir>'],
  21. testMatch: ['<rootDir>/test/unit/**/*.test.ts', '<rootDir>/test/unit/**/*.test.js'],
  22. testEnvironment: 'node',
  23. // Automatically clear mock calls and instances between every test
  24. clearMocks: true,
  25. moduleNameMapper: MODULE_NAME_MAPPING,
  26. },
  27. {
  28. displayName: 'server',
  29. transform: {
  30. '^.+\\.(t|j)sx?$': '@swc-node/jest',
  31. },
  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. transform: {
  48. '^.+\\.(t|j)sx?$': '@swc-node/jest',
  49. },
  50. rootDir: '.',
  51. roots: ['<rootDir>'],
  52. testMatch: ['<rootDir>/test/integration/**/v5.*.test.ts', '<rootDir>/test/integration/**/v5.*.test.js'],
  53. testEnvironment: 'node',
  54. globalSetup: '<rootDir>/test/integration/global-setup.js',
  55. globalTeardown: '<rootDir>/test/integration/global-teardown.js',
  56. setupFilesAfterEnv: ['<rootDir>/test/integration/setup.js'],
  57. // Automatically clear mock calls and instances between every test
  58. clearMocks: true,
  59. moduleNameMapper: MODULE_NAME_MAPPING,
  60. },
  61. ],
  62. // Automatically clear mock calls and instances between every test
  63. clearMocks: true,
  64. // Indicates whether the coverage information should be collected while executing the test
  65. collectCoverage: true,
  66. // An array of glob patterns indicating a set of files for which coverage information should be collected
  67. // collectCoverageFrom: undefined,
  68. // The directory where Jest should output its coverage files
  69. coverageDirectory: 'coverage',
  70. // An array of regexp pattern strings used to skip coverage collection
  71. coveragePathIgnorePatterns: [
  72. 'index.ts',
  73. '/config/',
  74. '/resource/',
  75. '/node_modules/',
  76. ],
  77. };