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

kulshekhar / ts-jest / 10066013409

23 Jul 2024 08:35PM UTC coverage: 95.254%. Remained the same
10066013409

push

github

ahnpnl
build(deps): Update dependency @testing-library/jest-dom to ^6.4.8

777 of 875 branches covered (88.8%)

Branch coverage included in aggregate %.

4763 of 4941 relevant lines covered (96.4%)

1242.48 hits per line

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

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

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

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

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

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

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

347✔
43
  if ('__TRANSFORM_HTML__' in globals) {
347✔
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

347✔
51
  if ('typeCheck' in tsJest) {
347!
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

347✔
57
  if ('tsConfigFile' in tsJest) {
347!
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

347✔
65
  if ('tsConfig' in tsJest) {
347!
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

347✔
73
  if ('enableTsDiagnostics' in tsJest) {
347!
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

347✔
84
  if ('useBabelrc' in tsJest) {
347!
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

347✔
92
  if ('skipBabel' in tsJest) {
347!
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

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

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

6✔
118
/**
6✔
119
 * @internal
6✔
120
 */
6✔
121
export const backportTsJestDebugEnvVar = (logger: Logger): void => {
6✔
122
  if ('TS_JEST_DEBUG' in process.env) {
6!
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
}
6✔
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