jest.config.js 2.5 KB

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