jest.config.js 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. // For a detailed explanation regarding each configuration property, visit:
  2. // https://jestjs.io/docs/en/configuration.html
  3. // https://kulshekhar.github.io/ts-jest/user/config/
  4. const MODULE_NAME_MAPPING = {
  5. '^\\^/(.+)$': '<rootDir>/$1',
  6. '^~/(.+)$': '<rootDir>/src/$1',
  7. '^@growi/(.+)$': '<rootDir>/../$1/src',
  8. };
  9. module.exports = {
  10. // Indicates whether each individual test should be reported during the run
  11. verbose: true,
  12. preset: 'ts-jest/presets/js-with-ts',
  13. projects: [
  14. {
  15. displayName: 'unit',
  16. preset: 'ts-jest/presets/js-with-ts',
  17. rootDir: '.',
  18. roots: ['<rootDir>'],
  19. testMatch: ['<rootDir>/test/unit/**/*.test.ts', '<rootDir>/test/unit/**/*.test.js'],
  20. testEnvironment: 'node',
  21. // Automatically clear mock calls and instances between every test
  22. clearMocks: true,
  23. moduleNameMapper: MODULE_NAME_MAPPING,
  24. },
  25. {
  26. displayName: 'server',
  27. preset: 'ts-jest/presets/js-with-ts',
  28. rootDir: '.',
  29. roots: ['<rootDir>'],
  30. testMatch: ['<rootDir>/test/integration/**/*.test.ts', '<rootDir>/test/integration/**/*.test.js',
  31. '?!<rootDir>/test/integration/**/v5.*.test.ts', '?!<rootDir>/test/integration/**/v5.*.test.js'],
  32. testEnvironment: 'node',
  33. globalSetup: '<rootDir>/test/integration/global-setup.js',
  34. globalTeardown: '<rootDir>/test/integration/global-teardown.js',
  35. setupFilesAfterEnv: ['<rootDir>/test/integration/setup.js'],
  36. // Automatically clear mock calls and instances between every test
  37. clearMocks: true,
  38. moduleNameMapper: MODULE_NAME_MAPPING,
  39. },
  40. {
  41. displayName: 'server-v5',
  42. preset: 'ts-jest/presets/js-with-ts',
  43. rootDir: '.',
  44. roots: ['<rootDir>'],
  45. testMatch: ['<rootDir>/test/integration/**/v5.*.test.ts', '<rootDir>/test/integration/**/v5.*.test.js'],
  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. };