|
1 | 1 | /* eslint-disable jest/no-mocks-import */ |
2 | 2 | import type { Transformer } from '@jest/transform' |
3 | | -import { testing } from 'bs-logger' |
| 3 | +import { LogLevels, testing } from 'bs-logger' |
4 | 4 | import { join, resolve } from 'path' |
5 | 5 | import ts from 'typescript' |
6 | 6 |
|
7 | 7 | import { logTargetMock } from '../__helpers__/mocks' |
8 | | -import { createConfigSet, defaultResolve } from '../__helpers__/fakers' |
9 | | -import type { TsJestGlobalOptions } from '../types' |
| 8 | +import { createConfigSet } from '../__helpers__/fakers' |
| 9 | +import type { TsJestGlobalOptions, TsJestConfig } from '../types' |
10 | 10 | import * as _backports from '../utils/backports' |
11 | 11 | import { getPackageVersion } from '../utils/get-package-version' |
12 | 12 | import { normalizeSlashes } from '../utils/normalize-slashes' |
@@ -151,40 +151,33 @@ describe('tsJest', () => { |
151 | 151 | }) |
152 | 152 |
|
153 | 153 | describe('packageJson', () => { |
154 | | - it('should be correct when packageJson is true', () => { |
155 | | - const EXPECTED = { |
156 | | - kind: 'file', |
157 | | - value: undefined, |
158 | | - } |
159 | | - expect(getTsJest().packageJson).toEqual(EXPECTED) |
160 | | - expect(getTsJest({ packageJson: true }).packageJson).toEqual(EXPECTED) |
161 | | - }) |
| 154 | + const logger = testing.createLoggerMock() |
| 155 | + let tsJestCfg: TsJestConfig |
162 | 156 |
|
163 | | - it('should be correct for given file as string', () => { |
164 | | - const FILE = 'bar/tsconfig.foo.json' |
165 | | - const EXPECTED = { |
166 | | - kind: 'file', |
167 | | - value: defaultResolve(FILE), |
168 | | - } |
169 | | - expect(getTsJest({ packageJson: FILE }).packageJson).toEqual(EXPECTED) |
| 157 | + beforeEach(() => { |
| 158 | + logger.target.clear() |
| 159 | + tsJestCfg = createConfigSet({ |
| 160 | + jestConfig: { |
| 161 | + globals: { |
| 162 | + 'ts-jest': { |
| 163 | + packageJson: true, |
| 164 | + }, |
| 165 | + }, |
| 166 | + } as any, |
| 167 | + logger, |
| 168 | + resolve: null, |
| 169 | + }).tsJest |
170 | 170 | }) |
171 | 171 |
|
172 | | - it('should be correct for given file as an object', () => { |
173 | | - const packageJsonStub = require('../__mocks__/package-foo.json') |
174 | | - const EXPECTED = { |
175 | | - kind: 'inline', |
176 | | - value: packageJsonStub, |
177 | | - } |
178 | | - expect(getTsJest({ packageJson: packageJsonStub }).packageJson).toEqual(EXPECTED) |
| 172 | + it('should not contain packageJson in final tsJest config', () => { |
| 173 | + expect(Object.keys(tsJestCfg)).not.toContain('packageJson') |
179 | 174 | }) |
180 | 175 |
|
181 | | - it('should be correct for inline config', () => { |
182 | | - const CONFIG = { foo: 'bar' } |
183 | | - const EXPECTED = { |
184 | | - kind: 'inline', |
185 | | - value: CONFIG, |
186 | | - } |
187 | | - expect(getTsJest({ packageJson: CONFIG as any }).packageJson).toEqual(EXPECTED) |
| 176 | + it('should show warning message when packageJson is provided', () => { |
| 177 | + expect(logger.target.filteredLines(LogLevels.warn)[0]).toMatchInlineSnapshot(` |
| 178 | + "[level:40] The option \`packageJson\` is deprecated and will be removed in ts-jest 27. This option is not used by internal \`ts-jest\` |
| 179 | + " |
| 180 | + `) |
188 | 181 | }) |
189 | 182 | }) |
190 | 183 |
|
|
0 commit comments