Skip to content

Commit

Permalink
refactor(config): remove support for packageJson option (#2128)
Browse files Browse the repository at this point in the history
BREAKING CHANGE:
`packageJson` config option is not used in internal `ts-jest` so this option is now removed
  • Loading branch information
ahnpnl authored Nov 11, 2020
1 parent 6bd101c commit 05916b9
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 185 deletions.
2 changes: 0 additions & 2 deletions docs/user/config/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ All options have default values which should fit most of the projects. Click on
| [**`diagnostics`**][diagnostics] | [Diagnostics related configuration.][diagnostics] | `boolean`\|`object` | _enabled_ |
| [**`babelConfig`**][babelConfig] | [Babel(Jest) related configuration.][babelConfig] | `boolean`\|`string`\|`object` | _disabled_ |
| [**`stringifyContentPathRegex`**][stringifyContentPathRegex] | [Files which will become modules returning self content.][stringifyContentPathRegex] | `string`\|`RegExp` | _disabled_ |
| [**`packageJson`**][packageJson] | [Package metadata.][packageJson] | `string`\|`object`\|`boolean` | _auto_ |

## Version checking

Expand Down Expand Up @@ -267,4 +266,3 @@ npx ts-jest config:migrate package.json
[diagnostics]: diagnostics
[babelConfig]: babelConfig
[stringifyContentPathRegex]: stringifyContentPathRegex
[packageJson]: packageJson
69 changes: 0 additions & 69 deletions docs/user/config/packageJson.md

This file was deleted.

57 changes: 0 additions & 57 deletions e2e/__tests__/__snapshots__/logger.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -127,63 +127,6 @@ Array [
]
`;
exports[`ts-jest logging deprecation warning with packageJson config should pass using template "default" 1`] = `
√ jest
↳ exit code: 0
===[ STDOUT ]===================================================================
===[ STDERR ]===================================================================
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\`
PASS ./Hello.spec.ts
Hello Class
√ should create a new Hello
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: XXs
Ran all test suites.
================================================================================
`;
exports[`ts-jest logging deprecation warning with packageJson config should pass using template "with-babel-7" 1`] = `
√ jest
↳ exit code: 0
===[ STDOUT ]===================================================================
===[ STDERR ]===================================================================
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\`
PASS ./Hello.spec.ts
Hello Class
√ should create a new Hello
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: XXs
Ran all test suites.
================================================================================
`;
exports[`ts-jest logging deprecation warning with packageJson config should pass using template "with-babel-7-string-config" 1`] = `
√ jest
↳ exit code: 0
===[ STDOUT ]===================================================================
===[ STDERR ]===================================================================
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\`
PASS ./Hello.spec.ts
Hello Class
√ should create a new Hello
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: XXs
Ran all test suites.
================================================================================
`;
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`] = `
√ jest
↳ exit code: 0
Expand Down
20 changes: 1 addition & 19 deletions e2e/__tests__/logger.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { LogContexts, LogLevels } from 'bs-logger'
import { existsSync } from 'fs'

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

describe('ts-jest logging', () => {
Expand Down Expand Up @@ -90,22 +90,4 @@ describe('ts-jest logging', () => {
})
})
}

describe('deprecation warning', () => {
describe('with packageJson config', () => {
const testCase = configureTestCase('simple', {
tsJestConfig: {
packageJson: true,
}
})

testCase.runWithTemplates(allPackageSetsWithPreset, 0, (runTest, { testLabel }) => {
it(testLabel, () => {
const result = runTest()
expect(result.status).toBe(0)
expect(result).toMatchSnapshot()
})
})
})
})
})
24 changes: 1 addition & 23 deletions src/config/config-set.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable jest/no-mocks-import */
import type { Transformer } from '@jest/transform'
import { LogLevels, testing } from 'bs-logger'
import { testing } from 'bs-logger'
import { join, resolve } from 'path'
import ts from 'typescript'

Expand Down Expand Up @@ -29,28 +29,6 @@ beforeEach(() => {
jest.clearAllMocks()
})

describe('packageJson', () => {
it('should not contain packageJson in final tsJest config', () => {
const logger = testing.createLoggerMock()
createConfigSet({
jestConfig: {
globals: {
'ts-jest': {
packageJson: true,
},
},
} as any,
resolve: null,
logger,
})

expect(logger.target.filteredLines(LogLevels.warn)[0]).toMatchInlineSnapshot(`
"[level:40] The option \`packageJson\` is deprecated and will be removed in ts-jest 27. This option is not used by internal \`ts-jest\`
"
`)
})
}) // packageJson

describe('parsedTsConfig', () => {
const get = (tsJest?: TsJestGlobalOptions) => createConfigSet({ tsJestConfig: tsJest }).parsedTsConfig

Expand Down
6 changes: 1 addition & 5 deletions src/config/config-set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import { importer } from '../utils/importer'
import { stringify } from '../utils/json'
import { rootLogger } from '../utils/logger'
import { Memoize } from '../utils/memoize'
import { Deprecations, Errors, ImportReasons, interpolate } from '../utils/messages'
import { Errors, ImportReasons, interpolate } from '../utils/messages'
import { normalizeSlashes } from '../utils/normalize-slashes'
import { sha1 } from '../utils/sha1'
import { TSError } from '../utils/ts-error'
Expand Down Expand Up @@ -206,10 +206,6 @@ export class ConfigSet {
* @internal
*/
private _setupTsJestCfg(options: TsJestGlobalOptions): void {
if (options.packageJson) {
this.logger.warn(Deprecations.PackageJson)
}

// babel config (for babel-jest) default is undefined so we don't need to have fallback like tsConfig
if (!options.babelConfig) {
this.logger.debug('babel is disabled')
Expand Down
10 changes: 0 additions & 10 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,6 @@ export interface TsJestGlobalOptions {
*/
tsconfig?: boolean | string | _ts.CompilerOptions

/**
* packageJson. It can be:
* - `true` (or `undefined`, it's the default): use default package.json file
* - `path/to/package.json`: path to a specific package.json file (<rootDir> can be used)
* - `{...}`: contents of a package.json
*
* @default undefined uses the default package.json file
*/
packageJson?: boolean | string | Record<string, unknown>

/**
* Compiles files as isolated modules (disables some features and type-checking)
*
Expand Down

0 comments on commit 05916b9

Please sign in to comment.