2
0

jest.config.js 2.1 KB

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