Skip to content

Commit 2f6c693

Browse files
committed
refactor(config): remove support for packageJson option
BREAKING CHANGE: `packageJson` config option is not used in internal `ts-jest` so this option is now removed
1 parent 1e0b2ce commit 2f6c693

7 files changed

Lines changed: 2 additions & 184 deletions

File tree

docs/user/config/index.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,6 @@ All options have default values which should fit most of the projects. Click on
213213
| [**`diagnostics`**][diagnostics] | [Diagnostics related configuration.][diagnostics] | `boolean`\|`object` | _enabled_ |
214214
| [**`babelConfig`**][babelConfig] | [Babel(Jest) related configuration.][babelConfig] | `boolean`\|`string`\|`object` | _disabled_ |
215215
| [**`stringifyContentPathRegex`**][stringifyContentPathRegex] | [Files which will become modules returning self content.][stringifyContentPathRegex] | `string`\|`RegExp` | _disabled_ |
216-
| [**`packageJson`**][packageJson] | [Package metadata.][packageJson] | `string`\|`object`\|`boolean` | _auto_ |
217216

218217
## Version checking
219218

@@ -267,4 +266,3 @@ npx ts-jest config:migrate package.json
267266
[diagnostics]: diagnostics
268267
[babelConfig]: babelConfig
269268
[stringifyContentPathRegex]: stringifyContentPathRegex
270-
[packageJson]: packageJson

docs/user/config/packageJson.md

Lines changed: 0 additions & 69 deletions
This file was deleted.

e2e/__tests__/__snapshots__/logger.test.ts.snap

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -127,63 +127,6 @@ Array [
127127
]
128128
`;
129129
130-
exports[`ts-jest logging deprecation warning with packageJson config should pass using template "default" 1`] = `
131-
√ jest
132-
↳ exit code: 0
133-
===[ STDOUT ]===================================================================
134-
135-
===[ STDERR ]===================================================================
136-
ts-jest[config] (WARN) The option \`packageJson\` is deprecated and will be removed in ts-jest 27. This option is not used by internal \`ts-jest\`
137-
PASS ./Hello.spec.ts
138-
Hello Class
139-
√ should create a new Hello
140-
141-
Test Suites: 1 passed, 1 total
142-
Tests: 1 passed, 1 total
143-
Snapshots: 0 total
144-
Time: XXs
145-
Ran all test suites.
146-
================================================================================
147-
`;
148-
149-
exports[`ts-jest logging deprecation warning with packageJson config should pass using template "with-babel-7" 1`] = `
150-
√ jest
151-
↳ exit code: 0
152-
===[ STDOUT ]===================================================================
153-
154-
===[ STDERR ]===================================================================
155-
ts-jest[config] (WARN) The option \`packageJson\` is deprecated and will be removed in ts-jest 27. This option is not used by internal \`ts-jest\`
156-
PASS ./Hello.spec.ts
157-
Hello Class
158-
√ should create a new Hello
159-
160-
Test Suites: 1 passed, 1 total
161-
Tests: 1 passed, 1 total
162-
Snapshots: 0 total
163-
Time: XXs
164-
Ran all test suites.
165-
================================================================================
166-
`;
167-
168-
exports[`ts-jest logging deprecation warning with packageJson config should pass using template "with-babel-7-string-config" 1`] = `
169-
√ jest
170-
↳ exit code: 0
171-
===[ STDOUT ]===================================================================
172-
173-
===[ STDERR ]===================================================================
174-
ts-jest[config] (WARN) The option \`packageJson\` is deprecated and will be removed in ts-jest 27. This option is not used by internal \`ts-jest\`
175-
PASS ./Hello.spec.ts
176-
Hello Class
177-
√ should create a new Hello
178-
179-
Test Suites: 1 passed, 1 total
180-
Tests: 1 passed, 1 total
181-
Snapshots: 0 total
182-
Time: XXs
183-
Ran all test suites.
184-
================================================================================
185-
`;
186-
187130
exports[`ts-jest logging with unsupported version test with TS_JEST_DISABLE_VER_CHECKER is not set in process.env should pass using template "with-unsupported-version" 1`] = `
188131
√ jest
189132
↳ exit code: 0

e2e/__tests__/logger.test.ts

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { LogContexts, LogLevels } from 'bs-logger'
22
import { existsSync } from 'fs'
33

4-
import { PackageSets, allValidPackageSets, allPackageSetsWithPreset } from '../__helpers__/templates'
4+
import { PackageSets, allValidPackageSets } from '../__helpers__/templates'
55
import { configureTestCase } from '../__helpers__/test-case'
66

77
describe('ts-jest logging', () => {
@@ -90,22 +90,4 @@ describe('ts-jest logging', () => {
9090
})
9191
})
9292
}
93-
94-
describe('deprecation warning', () => {
95-
describe('with packageJson config', () => {
96-
const testCase = configureTestCase('simple', {
97-
tsJestConfig: {
98-
packageJson: true,
99-
}
100-
})
101-
102-
testCase.runWithTemplates(allPackageSetsWithPreset, 0, (runTest, { testLabel }) => {
103-
it(testLabel, () => {
104-
const result = runTest()
105-
expect(result.status).toBe(0)
106-
expect(result).toMatchSnapshot()
107-
})
108-
})
109-
})
110-
})
11193
})

src/config/config-set.spec.ts

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable jest/no-mocks-import */
22
import type { Transformer } from '@jest/transform'
3-
import { LogLevels, testing } from 'bs-logger'
3+
import { testing } from 'bs-logger'
44
import { join, resolve } from 'path'
55
import ts from 'typescript'
66

@@ -29,28 +29,6 @@ beforeEach(() => {
2929
jest.clearAllMocks()
3030
})
3131

32-
describe('packageJson', () => {
33-
it('should not contain packageJson in final tsJest config', () => {
34-
const logger = testing.createLoggerMock()
35-
createConfigSet({
36-
jestConfig: {
37-
globals: {
38-
'ts-jest': {
39-
packageJson: true,
40-
},
41-
},
42-
} as any,
43-
resolve: null,
44-
logger,
45-
})
46-
47-
expect(logger.target.filteredLines(LogLevels.warn)[0]).toMatchInlineSnapshot(`
48-
"[level:40] The option \`packageJson\` is deprecated and will be removed in ts-jest 27. This option is not used by internal \`ts-jest\`
49-
"
50-
`)
51-
})
52-
}) // packageJson
53-
5432
describe('parsedTsConfig', () => {
5533
const get = (tsJest?: TsJestGlobalOptions) => createConfigSet({ tsJestConfig: tsJest }).parsedTsConfig
5634

src/config/config-set.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,6 @@ export class ConfigSet {
206206
* @internal
207207
*/
208208
private _setupTsJestCfg(options: TsJestGlobalOptions): void {
209-
if (options.packageJson) {
210-
this.logger.warn(Deprecations.PackageJson)
211-
}
212-
213209
// babel config (for babel-jest) default is undefined so we don't need to have fallback like tsConfig
214210
if (!options.babelConfig) {
215211
this.logger.debug('babel is disabled')

src/types.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,6 @@ export interface TsJestGlobalOptions {
5656
*/
5757
tsconfig?: boolean | string | _ts.CompilerOptions
5858

59-
/**
60-
* packageJson. It can be:
61-
* - `true` (or `undefined`, it's the default): use default package.json file
62-
* - `path/to/package.json`: path to a specific package.json file (<rootDir> can be used)
63-
* - `{...}`: contents of a package.json
64-
*
65-
* @default undefined uses the default package.json file
66-
*/
67-
packageJson?: boolean | string | Record<string, unknown>
68-
6959
/**
7060
* Compiles files as isolated modules (disables some features and type-checking)
7161
*

0 commit comments

Comments
 (0)