MCPcopy
hub / github.com/kulshekhar/ts-jest / createConfigSet

Function createConfigSet

src/__helpers__/fakers.ts:42–74  ·  view source on GitHub ↗
({
  jestConfig,
  tsJestConfig,
  logger, // don't change this key name, otherwise mock logging won't work
  resolve = defaultResolve,
  ...others
}: {
  jestConfig?: Partial<Config.ProjectConfig>
  tsJestConfig?: TsJestTransformerOptions
  logger?: Logger
  resolve?: ((path: string) => string) | null
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
  [key: string]: any
} = {})

Source from the content-addressed store, hash-verified

40export const defaultResolve = (path: string): string => `resolved:${path}`
41
42export function createConfigSet({
43 jestConfig,
44 tsJestConfig,
45 logger, // don't change this key name, otherwise mock logging won't work
46 resolve = defaultResolve,
47 ...others
48}: {
49 jestConfig?: Partial<Config.ProjectConfig>
50 tsJestConfig?: TsJestTransformerOptions
51 logger?: Logger
52 resolve?: ((path: string) => string) | null
53 // eslint-disable-next-line @typescript-eslint/no-explicit-any
54 [key: string]: any
55} = {}): ConfigSet {
56 const jestCfg = getJestConfig(jestConfig, tsJestConfig)
57 const cs = new ConfigSet(
58 {
59 ...jestCfg,
60 testMatch: jestConfig?.testMatch ? [...jestConfig.testMatch, ...defaultTestMatch] : defaultTestMatch,
61 testRegex: jestConfig?.testRegex ? [...jestConfig.testRegex, ...defaultTestRegex] : defaultTestRegex,
62 extensionsToTreatAsEsm: jestCfg.extensionsToTreatAsEsm ?? [],
63 },
64 logger,
65 )
66 if (resolve) {
67 cs.resolvePath = resolve
68 }
69 Object.keys(others).forEach((key) => {
70 Object.defineProperty(cs, key, { value: others[key] })
71 })
72
73 return cs
74}
75
76// not really unit-testing here, but it's hard to mock all those values :-D
77export function makeCompiler(

Callers 8

buildCompilerFunction · 0.90
getParsedTsconfigFunction · 0.90
config-set.spec.tsFile · 0.90
makeCompilerFunction · 0.85

Calls 1

getJestConfigFunction · 0.85

Tested by 4

buildCompilerFunction · 0.72
getParsedTsconfigFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…