jest.config.js 2.7 KB

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