• 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

85.96
/src/utils/backports.ts
1
import type { Config } from '@jest/types'
3✔
2
import { LogContexts, Logger } from 'bs-logger'
3✔
3

3✔
4
import { Deprecations, Helps, interpolate } from './messages'
3✔
5

3✔
6
const context = { [LogContexts.namespace]: 'backports' }
3✔
7

3✔
8
/**
3✔
9
 * @internal
3✔
10
 */
3✔
11
export const backportJestConfig = <T extends Config.InitialOptions | Config.ProjectConfig>(
3✔
12
  logger: Logger,
204✔
13
  config: T,
204✔
14
): T => {
204✔
15
  logger.debug({ ...context, config }, 'backporting config')
204✔
16

204✔
17
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
204✔
18
  const { globals = {} } = (config || {}) as any
204!
19
  const { 'ts-jest': tsJest = {} } = globals
204✔
20
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
204✔
21
  const mergeTsJest: any = {}
204✔
22
  let hadWarnings = false
204✔
23
  const warnConfig = (oldPath: string, newPath: string, note?: string) => {
204✔
24
    hadWarnings = true
65✔
25
    logger.warn(
65✔
26
      context,
65✔
27
      interpolate(note ? Deprecations.ConfigOptionWithNote : Deprecations.ConfigOption, {
65!
28
        oldPath,
65✔
29
        newPath,
65✔
30
        note,
65✔
31
      }),
65✔
32
    )
65✔
33
  }
65✔
34

204✔
35
  if ('__TS_CONFIG__' in globals) {
204✔
36
    warnConfig('globals.__TS_CONFIG__', 'globals.ts-jest.tsconfig')
10✔
37
    if (typeof globals.__TS_CONFIG__ === 'object') {
10✔
38
      mergeTsJest.tsconfig = globals.__TS_CONFIG__
10✔
39
    }
10✔
40
    delete globals.__TS_CONFIG__
10✔
41
  }
10✔
42

204✔
43
  if ('__TRANSFORM_HTML__' in globals) {
204✔
44
    warnConfig('globals.__TRANSFORM_HTML__', 'globals.ts-jest.stringifyContentPathRegex')
8✔
45
    if (globals.__TRANSFORM_HTML__) {
8✔
46
      mergeTsJest.stringifyContentPathRegex = '\\.html?$'
4✔
47
    }
4✔
48
    delete globals.__TRANSFORM_HTML__
8✔
49
  }
8✔
50

204✔
51
  if ('typeCheck' in tsJest) {
204!
52
    warnConfig('globals.ts-jest.typeCheck', 'globals.ts-jest.isolatedModules')
8✔
53
    mergeTsJest.isolatedModules = !tsJest.typeCheck
8✔
54
    delete tsJest.typeCheck
8✔
55
  }
8✔
56

204✔
57
  if ('tsConfigFile' in tsJest) {
204!
58
    warnConfig('globals.ts-jest.tsConfigFile', 'globals.ts-jest.tsconfig')
4✔
59
    if (tsJest.tsConfigFile) {
4✔
60
      mergeTsJest.tsconfig = tsJest.tsConfigFile
4✔
61
    }
4✔
62
    delete tsJest.tsConfigFile
4✔
63
  }
4✔
64

204✔
65
  if ('tsConfig' in tsJest) {
204!
66
    warnConfig('globals.ts-jest.tsConfig', 'globals.ts-jest.tsconfig')
4✔
67
    if (tsJest.tsConfig) {
4✔
68
      mergeTsJest.tsconfig = tsJest.tsConfig
4✔
69
    }
4✔
70
    delete tsJest.tsConfig
4✔
71
  }
4✔
72

204✔
73
  if ('enableTsDiagnostics' in tsJest) {
204!
74
    warnConfig('globals.ts-jest.enableTsDiagnostics', 'globals.ts-jest.diagnostics')
12✔
75
    if (tsJest.enableTsDiagnostics) {
12✔
76
      mergeTsJest.diagnostics = { warnOnly: true }
8✔
77
      if (typeof tsJest.enableTsDiagnostics === 'string') mergeTsJest.diagnostics.exclude = [tsJest.enableTsDiagnostics]
8✔
78
    } else {
12✔
79
      mergeTsJest.diagnostics = false
4✔
80
    }
4✔
81
    delete tsJest.enableTsDiagnostics
12✔
82
  }
12✔
83

204✔
84
  if ('useBabelrc' in tsJest) {
204!
85
    warnConfig('globals.ts-jest.useBabelrc', 'globals.ts-jest.babelConfig', Deprecations.ConfigOptionUseBabelRcNote)
8✔
86
    if (tsJest.useBabelrc != null) {
8✔
87
      mergeTsJest.babelConfig = tsJest.useBabelrc ? true : {}
8✔
88
    }
8✔
89
    delete tsJest.useBabelrc
8✔
90
  }
8✔
91

204✔
92
  if ('skipBabel' in tsJest) {
204!
93
    warnConfig('globals.ts-jest.skipBabel', 'globals.ts-jest.babelConfig')
8✔
94
    if (tsJest.skipBabel === false && !mergeTsJest.babelConfig) {
8✔
95
      mergeTsJest.babelConfig = true
4✔
96
    }
4✔
97
    delete tsJest.skipBabel
8✔
98
  }
8✔
99

204✔
100
  // if we had some warnings we can inform the user about the CLI tool
204✔
101
  if (hadWarnings) {
204!
102
    logger.warn(context, Helps.MigrateConfigUsingCLI)
62✔
103
  }
62✔
104

204✔
105
  return {
204✔
106
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
204✔
107
    ...(config as any),
204✔
108
    globals: {
204✔
109
      ...globals,
204✔
110
      'ts-jest': {
204✔
111
        ...mergeTsJest,
204✔
112
        ...tsJest,
204✔
113
      },
204✔
114
    },
204✔
115
  }
204✔
116
}
204✔
117

3✔
118
/**
3✔
119
 * @internal
3✔
120
 */
3✔
121
export const backportTsJestDebugEnvVar = (logger: Logger): void => {
3✔
122
  if ('TS_JEST_DEBUG' in process.env) {
3!
123
    const shouldLog = !/^\s*(?:0|f(?:alse)?|no?|disabled?|off|)\s*$/i.test(process.env.TS_JEST_DEBUG || '')
×
124
    delete process.env.TS_JEST_DEBUG
×
125
    if (shouldLog) {
×
126
      process.env.TS_JEST_LOG = 'ts-jest.log,stderr:warn'
×
127
    }
×
128
    logger.warn(
×
129
      context,
×
130
      interpolate(Deprecations.EnvVar, {
×
131
        old: 'TS_JEST_DEBUG',
×
132
        new: 'TS_JEST_LOG',
×
133
      }),
×
134
    )
×
135
  }
×
136
}
3✔
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