jest.config.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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>/src'],
  19. testMatch: ['<rootDir>/src/test/unit/**/*.test.ts', '<rootDir>/src/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>/src'],
  30. testMatch: ['<rootDir>/src/test/integration/**/*.test.ts', '<rootDir>/src/test/integration/**/*.test.js'],
  31. testEnvironment: 'node',
  32. globalSetup: '<rootDir>/src/test/integration/global-setup.js',
  33. globalTeardown: '<rootDir>/src/test/integration/global-teardown.js',
  34. setupFilesAfterEnv: ['<rootDir>/src/test/integration/setup.js'],
  35. // Automatically clear mock calls and instances between every test
  36. clearMocks: true,
  37. moduleNameMapper: MODULE_NAME_MAPPING,
  38. },
  39. // {
  40. // displayName: 'client',
  41. // rootDir: '.',
  42. // testMatch: ['<rootDir>/src/test/client/**/*.test.js'],
  43. // },
  44. ],
  45. // Automatically clear mock calls and instances between every test
  46. clearMocks: true,
  47. // Indicates whether the coverage information should be collected while executing the test
  48. collectCoverage: true,
  49. // An array of glob patterns indicating a set of files for which coverage information should be collected
  50. // collectCoverageFrom: undefined,
  51. // The directory where Jest should output its coverage files
  52. coverageDirectory: 'coverage',
  53. // An array of regexp pattern strings used to skip coverage collection
  54. coveragePathIgnorePatterns: [
  55. 'index.ts',
  56. '/config/',
  57. '/resource/',
  58. '/node_modules/',
  59. ],
  60. };