jest.config.js 1.8 KB

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