jest.config.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. globalSetup: '<rootDir>/src/test/global-setup.js',
  14. globalTeardown: '<rootDir>/src/test/global-teardown.js',
  15. projects: [
  16. {
  17. displayName: 'server',
  18. preset: 'ts-jest/presets/js-with-ts',
  19. rootDir: '.',
  20. roots: ['<rootDir>/src'],
  21. testEnvironment: 'node',
  22. setupFilesAfterEnv: ['<rootDir>/src/test/setup.js'],
  23. testMatch: ['<rootDir>/src/test/**/*.test.ts', '<rootDir>/src/test/**/*.test.js'],
  24. // Automatically clear mock calls and instances between every test
  25. clearMocks: true,
  26. moduleNameMapper: MODULE_NAME_MAPPING,
  27. },
  28. // {
  29. // displayName: 'client',
  30. // rootDir: '.',
  31. // testMatch: ['<rootDir>/src/test/client/**/*.test.js'],
  32. // },
  33. ],
  34. // Automatically clear mock calls and instances between every test
  35. clearMocks: true,
  36. // Indicates whether the coverage information should be collected while executing the test
  37. collectCoverage: true,
  38. // An array of glob patterns indicating a set of files for which coverage information should be collected
  39. // collectCoverageFrom: undefined,
  40. // The directory where Jest should output its coverage files
  41. coverageDirectory: 'coverage',
  42. // An array of regexp pattern strings used to skip coverage collection
  43. coveragePathIgnorePatterns: [
  44. 'index.ts',
  45. '/config/',
  46. '/resource/',
  47. '/node_modules/',
  48. ],
  49. };