jest.config.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // For a detailed explanation regarding each configuration property, visit:
  2. // https://jestjs.io/docs/en/configuration.html
  3. const MODULE_NAME_MAPPING = {
  4. '@root/(.+)': '<rootDir>/$1',
  5. '@commons/(.+)': '<rootDir>/src/lib/$1',
  6. '@server/(.+)': '<rootDir>/src/server/$1',
  7. '@alias/logger': '<rootDir>/src/lib/service/logger',
  8. // -- doesn't work with unknown error -- 2019.06.19 Yuki Takei
  9. // debug: '<rootDir>/src/lib/service/logger/alias-for-debug',
  10. };
  11. module.exports = {
  12. // Indicates whether each individual test should be reported during the run
  13. verbose: true,
  14. rootDir: '../',
  15. globalSetup: '<rootDir>/src/test/global-setup.js',
  16. globalTeardown: '<rootDir>/src/test/global-teardown.js',
  17. projects: [
  18. {
  19. displayName: 'server',
  20. testEnvironment: 'node',
  21. rootDir: '.',
  22. setupFilesAfterEnv: ['<rootDir>/src/test/setup.js'],
  23. testMatch: ['<rootDir>/src/test/**/*.test.js'],
  24. // Automatically clear mock calls and instances between every test
  25. clearMocks: true,
  26. // A map from regular expressions to module names that allow to stub out resources with a single module
  27. moduleNameMapper: MODULE_NAME_MAPPING,
  28. },
  29. // {
  30. // displayName: 'client',
  31. // rootDir: '.',
  32. // testMatch: ['<rootDir>/src/test/client/**/*.test.js'],
  33. // },
  34. ],
  35. // Indicates whether the coverage information should be collected while executing the test
  36. // collectCoverage: false,
  37. // An array of glob patterns indicating a set of files for which coverage information should be collected
  38. collectCoverageFrom: [
  39. 'src/client/**/*.js',
  40. 'src/lib/**/*.js',
  41. 'src/migrations/**/*.js',
  42. 'src/server/**/*.js',
  43. ],
  44. // The directory where Jest should output its coverage files
  45. coverageDirectory: 'coverage',
  46. };