• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

kulshekhar / ts-jest / 4440110611

pending completion
4440110611

push

github

GitHub
build(deps): Update dependency eslint to ^8.36.0 (#4045)

930 of 1044 branches covered (89.08%)

Branch coverage included in aggregate %.

4055 of 4154 relevant lines covered (97.62%)

520.62 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.35
/src/__helpers__/fakers.ts
1
import { resolve } from 'path'
3✔
2

3✔
3
import type { Config } from '@jest/types'
3✔
4
import type { Logger } from 'bs-logger'
3✔
5

3✔
6
import { TsCompiler } from '../legacy/compiler'
3✔
7
import { ConfigSet } from '../legacy/config/config-set'
3✔
8
import type { StringMap, TsJestGlobalOptions } from '../types'
3✔
9
import type { ImportReasons } from '../utils/messages'
3✔
10

3✔
11
export function filePath(relPath: string): string {
14✔
12
  return resolve(__dirname, '..', '..', relPath)
14✔
13
}
14✔
14

3✔
15
export const rootDir = filePath('')
3✔
16

3✔
17
const defaultTestRegex = ['(/__tests__/.*|(\\\\.|/)(test|spec))\\\\.[jt]sx?$']
3✔
18
const defaultTestMatch = ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)']
3✔
19

3✔
20
function getJestConfig<T extends Config.ProjectConfig>(
280✔
21
  options?: Partial<Config.InitialOptions | Config.ProjectConfig>,
280✔
22
  tsJestOptions?: TsJestGlobalOptions,
280✔
23
): T {
280✔
24
  const res = {
280✔
25
    globals: {},
280✔
26
    ...options,
280✔
27
  } as any // eslint-disable-line @typescript-eslint/no-explicit-any
280✔
28
  if (tsJestOptions) {
280✔
29
    res.globals['ts-jest'] = tsJestOptions
175✔
30
  }
175✔
31

280✔
32
  return res
280✔
33
}
280✔
34

3✔
35
export function importReason(text = '[[BECAUSE]]'): ImportReasons {
15✔
36
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
15✔
37
  return text as any
15✔
38
}
15✔
39

3✔
40
export const defaultResolve = (path: string): string => `resolved:${path}`
3✔
41

3✔
42
export function createConfigSet({
280✔
43
  jestConfig,
280✔
44
  tsJestConfig,
280✔
45
  logger, // don't change this key name, otherwise mock logging won't work
280✔
46
  resolve = defaultResolve,
280✔
47
  ...others
280✔
48
}: {
280✔
49
  jestConfig?: Partial<Config.ProjectConfig>
280✔
50
  tsJestConfig?: TsJestGlobalOptions
280✔
51
  logger?: Logger
280✔
52
  resolve?: ((path: string) => string) | null
280✔
53
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
280✔
54
  [key: string]: any
280✔
55
} = {}): ConfigSet {
280✔
56
  const jestCfg = getJestConfig(jestConfig, tsJestConfig)
280✔
57
  const cs = new ConfigSet(
280✔
58
    {
280✔
59
      ...jestCfg,
280✔
60
      testMatch: jestConfig?.testMatch ? [...jestConfig.testMatch, ...defaultTestMatch] : defaultTestMatch,
280✔
61
      testRegex: jestConfig?.testRegex ? [...jestConfig.testRegex, ...defaultTestRegex] : defaultTestRegex,
280✔
62
      extensionsToTreatAsEsm: jestCfg.extensionsToTreatAsEsm ?? [],
280✔
63
    },
280✔
64
    logger,
280✔
65
  )
280✔
66
  if (resolve) {
280✔
67
    cs.resolvePath = resolve
161✔
68
  }
161✔
69
  Object.keys(others).forEach((key) => {
277✔
70
    Object.defineProperty(cs, key, { value: others[key] })
56✔
71
  })
277✔
72

277✔
73
  return cs
277✔
74
}
277✔
75

3✔
76
// not really unit-testing here, but it's hard to mock all those values :-D
3✔
77
export function makeCompiler(
64✔
78
  {
64✔
79
    jestConfig,
64✔
80
    tsJestConfig,
64✔
81
    parentConfig,
64✔
82
  }: {
64✔
83
    jestConfig?: Partial<Config.ProjectConfig>
64✔
84
    tsJestConfig?: TsJestGlobalOptions
64✔
85
    parentConfig?: TsJestGlobalOptions
64✔
86
  } = {},
64✔
87
  jestCacheFS: StringMap = new Map<string, string>(),
64✔
88
): TsCompiler {
64✔
89
  tsJestConfig = { ...tsJestConfig }
64✔
90
  tsJestConfig.diagnostics = {
64✔
91
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
64✔
92
    ...(tsJestConfig.diagnostics as any),
64✔
93
    pretty: false,
64✔
94
  }
64✔
95
  jestConfig = {
64✔
96
    ...jestConfig,
64✔
97
    extensionsToTreatAsEsm: jestConfig?.extensionsToTreatAsEsm ?? [],
64!
98
    testMatch: jestConfig?.testMatch ? [...jestConfig.testMatch, ...defaultTestMatch] : defaultTestMatch,
64!
99
    testRegex: jestConfig?.testRegex ? [...jestConfig.testRegex, ...defaultTestRegex] : defaultTestRegex,
64!
100
  }
64✔
101
  const cs = createConfigSet({ jestConfig, tsJestConfig, parentConfig, resolve: null })
64✔
102

64✔
103
  return new TsCompiler(cs, jestCacheFS)
64✔
104
}
64✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc