jest.config.cjs 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. // For a detailed explanation regarding each configuration property, visit:
  2. // https://jestjs.io/docs/en/configuration.html
  3. const { compilerOptions: tsconfig } = JSON.parse(
  4. require('fs').readFileSync('./tsconfig.node.json')
  5. );
  6. module.exports = {
  7. globals: {
  8. 'ts-jest': {
  9. tsconfig,
  10. },
  11. },
  12. // All imported modules in your tests should be mocked automatically
  13. // automock: false,
  14. // Stop running tests after `n` failures
  15. // bail: 0,
  16. // The directory where Jest should store its cached dependency information
  17. // cacheDirectory: "/private/var/folders/_g/g97k3tbx31x08qqy2z18kxq80000gn/T/jest_dx",
  18. // Automatically clear mock calls and instances between every test
  19. // clearMocks: false,
  20. // Indicates whether the coverage information should be collected while executing the test
  21. collectCoverage: true,
  22. // An array of glob patterns indicating a set of files for which coverage information should be collected
  23. // collectCoverageFrom: undefined,
  24. // The directory where Jest should output its coverage files
  25. // coverageDirectory: ".coverage",
  26. // An array of regexp pattern strings used to skip coverage collection
  27. coveragePathIgnorePatterns: ['/node_modules/', '/lib/', '/tests/'],
  28. // Indicates which provider should be used to instrument code for coverage
  29. coverageProvider: 'v8',
  30. // A list of reporter names that Jest uses when writing coverage reports
  31. // coverageReporters: [
  32. // "json",
  33. // "text",
  34. // "lcov",
  35. // "clover"
  36. // ],
  37. // An object that configures minimum threshold enforcement for coverage results
  38. // coverageThreshold: {
  39. // global : {
  40. // branches: 85,
  41. // functions: 85,
  42. // lines: 85,
  43. // statements: 85
  44. // }
  45. // },
  46. // A path to a custom dependency extractor
  47. // dependencyExtractor: undefined,
  48. // Make calling deprecated APIs throw helpful error messages
  49. // errorOnDeprecated: false,
  50. // Force coverage collection from ignored files using an array of glob patterns
  51. // forceCoverageMatch: [],
  52. // A path to a module which exports an async function that is triggered once before all test suites
  53. // globalSetup: undefined,
  54. // A path to a module which exports an async function that is triggered once after all test suites
  55. // globalTeardown: undefined,
  56. // A set of global variables that need to be available in all test environments
  57. // globals: {},
  58. // The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
  59. // maxWorkers: "50%",
  60. // An array of directory names to be searched recursively up from the requiring module's location
  61. // moduleDirectories: [
  62. // "node_modules"
  63. // ],
  64. // An array of file extensions your modules use
  65. // moduleFileExtensions: [
  66. // "js",
  67. // "json",
  68. // "jsx",
  69. // "ts",
  70. // "tsx",
  71. // "node"
  72. // ],
  73. // A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
  74. moduleNameMapper: {
  75. [/(.+)\.js$/.source]: ['$1.js', '$1.ts']
  76. },
  77. // An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
  78. // modulePathIgnorePatterns: [],
  79. // Activates notifications for test results
  80. // notify: false,
  81. // An enum that specifies notification mode. Requires { notify: true }
  82. // notifyMode: "failure-change",
  83. // A preset that is used as a base for Jest's configuration
  84. preset: 'ts-jest',
  85. // Run tests from one or more projects
  86. // projects: undefined,
  87. // Use this configuration option to add custom reporters to Jest
  88. // reporters: undefined,
  89. // Automatically reset mock state between every test
  90. // resetMocks: false,
  91. // Reset the module registry before running each individual test
  92. // resetModules: false,
  93. // A path to a custom resolver
  94. // resolver: undefined,
  95. // Automatically restore mock state between every test
  96. // restoreMocks: false,
  97. // The root directory that Jest should scan for tests and modules within
  98. // rootDir: undefined,
  99. // A list of paths to directories that Jest should use to search for files in
  100. roots: ['<rootDir>/tests/'],
  101. // Allows you to use a custom runner instead of Jest's default test runner
  102. // runner: "jest-runner",
  103. // The paths to modules that run some code to configure or set up the testing environment before each test
  104. // setupFiles: [],
  105. // A list of paths to modules that run some code to configure or set up the testing framework before each test
  106. // setupFilesAfterEnv: [],
  107. // The number of seconds after which a test is considered as slow and reported as such in the results.
  108. // slowTestThreshold: 5,
  109. // A list of paths to snapshot serializer modules Jest should use for snapshot testing
  110. // snapshotSerializers: [],
  111. // The test environment that will be used for testing
  112. testEnvironment: 'node',
  113. // Options that will be passed to the testEnvironment
  114. // testEnvironmentOptions: {},
  115. // Adds a location field to test results
  116. // testLocationInResults: false,
  117. // The glob patterns Jest uses to detect test files
  118. // testMatch: [
  119. // "**/__tests__/**/*.[jt]s?(x)",
  120. // "**/?(*.)+(spec|test).[tj]s?(x)"
  121. // ],
  122. // An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
  123. // testPathIgnorePatterns: [
  124. // "/node_modules/"
  125. // ],
  126. // The regexp pattern or array of patterns that Jest uses to detect test files
  127. // testRegex: [],
  128. // This option allows the use of a custom results processor
  129. // testResultsProcessor: undefined,
  130. // This option allows use of a custom test runner
  131. // testRunner: "jasmine2",
  132. // This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
  133. // testURL: "http://localhost",
  134. // Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"
  135. // timers: "real",
  136. // A map from regular expressions to paths to transformers
  137. transform: {
  138. '^.+\\.ts$': 'ts-jest',
  139. },
  140. // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
  141. // transformIgnorePatterns: [
  142. // "/node_modules/",
  143. // "\\.pnp\\.[^\\/]+$"
  144. // ],
  145. // An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
  146. // unmockedModulePathPatterns: undefined,
  147. // Indicates whether each individual test should be reported during the run
  148. // verbose: undefined,
  149. // An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
  150. // watchPathIgnorePatterns: [],
  151. // Whether to use watchman for file crawling
  152. // watchman: true,
  153. };