Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow subclass of TsJestTransformer to have version checking #2176

Merged
merged 1 commit into from Dec 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion e2e/__external-repos__/custom-typings/package.json
Expand Up @@ -5,7 +5,7 @@
"test": "jest"
},
"devDependencies": {
"@types/jest": "^26.0.15",
"@types/jest": "^26.0.16",
"@types/jquery": "^3.5.4",
"jest": "^26.6.3",
"jquery": "^3.5.1",
Expand Down
8 changes: 4 additions & 4 deletions e2e/__external-repos__/custom-typings/yarn.lock
Expand Up @@ -578,10 +578,10 @@
dependencies:
"@types/istanbul-lib-report" "*"

"@types/jest@^26.0.15":
version "26.0.15"
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-26.0.15.tgz#12e02c0372ad0548e07b9f4e19132b834cb1effe"
integrity sha512-s2VMReFXRg9XXxV+CW9e5Nz8fH2K1aEhwgjUqPPbQd7g95T0laAcvLv032EhFHIa5GHsZ8W7iJEQVaJq6k3Gog==
"@types/jest@^26.0.16":
version "26.0.16"
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-26.0.16.tgz#b47abd50f6ed0503f589db8e126fc8eb470cf87c"
integrity sha512-Gp12+7tmKCgv9JjtltxUXokohCAEZfpJaEW5tn871SGRp8I+bRWBonQO7vW5NHwnAHe5dd50+Q4zyKuN35i09g==
dependencies:
jest-diff "^26.0.0"
pretty-format "^26.0.0"
Expand Down
2 changes: 1 addition & 1 deletion e2e/__external-repos__/memory-usage/package.json
Expand Up @@ -28,7 +28,7 @@
"@nestjs/core": "^7.5.5",
"@nestjs/platform-express": "^7.5.5",
"@nestjs/testing": "^7.5.5",
"@types/jest": "^26.0.15",
"@types/jest": "^26.0.16",
"@types/lodash": "^4.14.165",
"jest": "^26.6.3",
"lodash": "^4.17.20",
Expand Down
8 changes: 4 additions & 4 deletions e2e/__external-repos__/memory-usage/yarn.lock
Expand Up @@ -601,10 +601,10 @@
dependencies:
"@types/istanbul-lib-report" "*"

"@types/jest@^26.0.15":
version "26.0.15"
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-26.0.15.tgz#12e02c0372ad0548e07b9f4e19132b834cb1effe"
integrity sha512-s2VMReFXRg9XXxV+CW9e5Nz8fH2K1aEhwgjUqPPbQd7g95T0laAcvLv032EhFHIa5GHsZ8W7iJEQVaJq6k3Gog==
"@types/jest@^26.0.16":
version "26.0.16"
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-26.0.16.tgz#b47abd50f6ed0503f589db8e126fc8eb470cf87c"
integrity sha512-Gp12+7tmKCgv9JjtltxUXokohCAEZfpJaEW5tn871SGRp8I+bRWBonQO7vW5NHwnAHe5dd50+Q4zyKuN35i09g==
dependencies:
jest-diff "^26.0.0"
pretty-format "^26.0.0"
Expand Down
2 changes: 1 addition & 1 deletion e2e/__external-repos__/path-mapping/package.json
Expand Up @@ -2,7 +2,7 @@
"name": "ts-jest-example",
"private": true,
"devDependencies": {
"@types/jest": "^26.0.15",
"@types/jest": "^26.0.16",
"jest": "^26.6.3",
"typescript": "^4.1.2"
},
Expand Down
8 changes: 4 additions & 4 deletions e2e/__external-repos__/path-mapping/yarn.lock
Expand Up @@ -561,10 +561,10 @@
dependencies:
"@types/istanbul-lib-report" "*"

"@types/jest@^26.0.15":
version "26.0.15"
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-26.0.15.tgz#12e02c0372ad0548e07b9f4e19132b834cb1effe"
integrity sha512-s2VMReFXRg9XXxV+CW9e5Nz8fH2K1aEhwgjUqPPbQd7g95T0laAcvLv032EhFHIa5GHsZ8W7iJEQVaJq6k3Gog==
"@types/jest@^26.0.16":
version "26.0.16"
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-26.0.16.tgz#b47abd50f6ed0503f589db8e126fc8eb470cf87c"
integrity sha512-Gp12+7tmKCgv9JjtltxUXokohCAEZfpJaEW5tn871SGRp8I+bRWBonQO7vW5NHwnAHe5dd50+Q4zyKuN35i09g==
dependencies:
jest-diff "^26.0.0"
pretty-format "^26.0.0"
Expand Down
Expand Up @@ -5,7 +5,7 @@
"test": "jest"
},
"devDependencies": {
"@types/jest": "^26.0.15",
"@types/jest": "^26.0.16",
"@types/lodash": "^4.14.165",
"jest": "^26.6.3",
"typescript": "^4.1.2"
Expand Down
8 changes: 4 additions & 4 deletions e2e/__external-repos__/simple-project-references/yarn.lock
Expand Up @@ -578,10 +578,10 @@
dependencies:
"@types/istanbul-lib-report" "*"

"@types/jest@^26.0.15":
version "26.0.15"
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-26.0.15.tgz#12e02c0372ad0548e07b9f4e19132b834cb1effe"
integrity sha512-s2VMReFXRg9XXxV+CW9e5Nz8fH2K1aEhwgjUqPPbQd7g95T0laAcvLv032EhFHIa5GHsZ8W7iJEQVaJq6k3Gog==
"@types/jest@^26.0.16":
version "26.0.16"
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-26.0.16.tgz#b47abd50f6ed0503f589db8e126fc8eb470cf87c"
integrity sha512-Gp12+7tmKCgv9JjtltxUXokohCAEZfpJaEW5tn871SGRp8I+bRWBonQO7vW5NHwnAHe5dd50+Q4zyKuN35i09g==
dependencies:
jest-diff "^26.0.0"
pretty-format "^26.0.0"
Expand Down
2 changes: 1 addition & 1 deletion e2e/__external-repos__/simple/with-dependency/package.json
Expand Up @@ -36,7 +36,7 @@
}
},
"devDependencies": {
"@types/jest": "^26.0.15",
"@types/jest": "^26.0.16",
"dependency": "file:../dependency",
"jest": "^26.6.3",
"typescript": "^4.1.2"
Expand Down
8 changes: 4 additions & 4 deletions e2e/__external-repos__/simple/with-dependency/yarn.lock
Expand Up @@ -578,10 +578,10 @@
dependencies:
"@types/istanbul-lib-report" "*"

"@types/jest@^26.0.15":
version "26.0.15"
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-26.0.15.tgz#12e02c0372ad0548e07b9f4e19132b834cb1effe"
integrity sha512-s2VMReFXRg9XXxV+CW9e5Nz8fH2K1aEhwgjUqPPbQd7g95T0laAcvLv032EhFHIa5GHsZ8W7iJEQVaJq6k3Gog==
"@types/jest@^26.0.16":
version "26.0.16"
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-26.0.16.tgz#b47abd50f6ed0503f589db8e126fc8eb470cf87c"
integrity sha512-Gp12+7tmKCgv9JjtltxUXokohCAEZfpJaEW5tn871SGRp8I+bRWBonQO7vW5NHwnAHe5dd50+Q4zyKuN35i09g==
dependencies:
jest-diff "^26.0.0"
pretty-format "^26.0.0"
Expand Down
Expand Up @@ -8,7 +8,7 @@
"test": "jest --no-cache"
},
"devDependencies": {
"@types/jest": "^26.0.15",
"@types/jest": "^26.0.16",
"jest": "^26.6.3",
"typescript": "^4.1.2"
},
Expand Down
8 changes: 4 additions & 4 deletions e2e/__external-repos__/yarn-workspace-composite/yarn.lock
Expand Up @@ -578,10 +578,10 @@
dependencies:
"@types/istanbul-lib-report" "*"

"@types/jest@^26.0.15":
version "26.0.15"
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-26.0.15.tgz#12e02c0372ad0548e07b9f4e19132b834cb1effe"
integrity sha512-s2VMReFXRg9XXxV+CW9e5Nz8fH2K1aEhwgjUqPPbQd7g95T0laAcvLv032EhFHIa5GHsZ8W7iJEQVaJq6k3Gog==
"@types/jest@^26.0.16":
version "26.0.16"
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-26.0.16.tgz#b47abd50f6ed0503f589db8e126fc8eb470cf87c"
integrity sha512-Gp12+7tmKCgv9JjtltxUXokohCAEZfpJaEW5tn871SGRp8I+bRWBonQO7vW5NHwnAHe5dd50+Q4zyKuN35i09g==
dependencies:
jest-diff "^26.0.0"
pretty-format "^26.0.0"
Expand Down
14 changes: 7 additions & 7 deletions e2e/__templates__/default/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion e2e/__templates__/default/package.json
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.0-tmpl.0",
"private": true,
"devDependencies": {
"@types/jest": "26.0.15",
"@types/jest": "26.0.16",
"@types/node": "12.19.0",
"jest": "26.6.3",
"typescript": "4.1.2"
Expand Down
14 changes: 7 additions & 7 deletions e2e/__templates__/with-babel-7-string-config/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion e2e/__templates__/with-babel-7-string-config/package.json
Expand Up @@ -5,7 +5,7 @@
"devDependencies": {
"@babel/core": "7.12.3",
"@babel/preset-env": "7.12.1",
"@types/jest": "26.0.15",
"@types/jest": "26.0.16",
"@types/node": "12.19.0",
"babel-jest": "26.6.3",
"jest": "26.6.3",
Expand Down
14 changes: 7 additions & 7 deletions e2e/__templates__/with-babel-7/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion e2e/__templates__/with-babel-7/package.json
Expand Up @@ -5,7 +5,7 @@
"devDependencies": {
"@babel/core": "7.12.3",
"@babel/preset-env": "7.12.1",
"@types/jest": "26.0.15",
"@types/jest": "26.0.16",
"@types/node": "12.19.0",
"babel-jest": "26.6.3",
"jest": "26.6.3",
Expand Down
14 changes: 7 additions & 7 deletions e2e/__templates__/with-unsupported-version/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion e2e/__templates__/with-unsupported-version/package.json
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.0-tmpl.0",
"private": true,
"devDependencies": {
"@types/jest": "26.0.15",
"@types/jest": "26.0.16",
"@types/node": "12.19.0",
"jest": "26.6.3",
"typescript": "3.7.5"
Expand Down
3 changes: 0 additions & 3 deletions src/index.ts
@@ -1,8 +1,5 @@
import { VersionCheckers } from './utils/version-checkers'
import { TsJestTransformer } from './ts-jest-transformer'

export function createTransformer(): TsJestTransformer {
VersionCheckers.jest.warn()

return new TsJestTransformer()
}
13 changes: 13 additions & 0 deletions src/ts-jest-transformer.spec.ts
Expand Up @@ -13,6 +13,7 @@ import { CACHE_KEY_EL_SEPARATOR, TsJestTransformer } from './ts-jest-transformer
import type { ResolvedModulesMap } from './types'
import { stringify } from './utils/json'
import { sha1 } from './utils/sha1'
import { VersionCheckers } from './utils/version-checkers'

const logTarget = logTargetMock()
const cacheDir = join(process.cwd(), 'tmp')
Expand Down Expand Up @@ -360,4 +361,16 @@ describe('TsJestTransformer', () => {
}
})
})

describe('subclass extends TsJestTransformer', () => {
class MyTransformer extends TsJestTransformer {}

test('should have jest version checking', () => {
VersionCheckers.jest.warn = jest.fn()

new MyTransformer()

expect(VersionCheckers.jest.warn).toHaveBeenCalled()
})
})
})
2 changes: 2 additions & 0 deletions src/ts-jest-transformer.ts
Expand Up @@ -14,6 +14,7 @@ import { rootLogger } from './utils/logger'
import { Errors, interpolate } from './utils/messages'
import type { CompilerInstance } from './types'
import { sha1 } from './utils/sha1'
import { VersionCheckers } from './utils/version-checkers'

interface CachedConfigSet {
configSet: ConfigSet
Expand Down Expand Up @@ -47,6 +48,7 @@ export class TsJestTransformer implements Transformer {

constructor() {
this._logger = rootLogger.child({ namespace: 'ts-jest-transformer' })
VersionCheckers.jest.warn()

this._logger.debug('created new transformer')
}
Expand Down