diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 401ff68854..4d1e45a378 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -75,7 +75,7 @@ jobs: - name: Install and build run: npm ci - name: Run tests with coverage - run: npm run test-ci -- --coverage && cat ./coverage/lcov.info + run: npm run test -- --coverage && cat ./coverage/lcov.info env: CI: true - name: Coveralls parallel diff --git a/.gitignore b/.gitignore index bc66b30bc2..5746dd72d6 100644 --- a/.gitignore +++ b/.gitignore @@ -45,14 +45,8 @@ jspm_packages .idea .cache -# tests specific -tests/simple-long-path/long-src-path # is linked to the temp dir of the os -e2e/__workdir_synlink__ -**/.ts-jest-e2e.json .ts-jest-digest -# while refactoring... -old/ # binaries *.tgz diff --git a/.npmignore b/.npmignore index 0796f6c422..618296fec5 100644 --- a/.npmignore +++ b/.npmignore @@ -26,6 +26,7 @@ jest-base.js # Tsconfig tsconfig.build.json +tsconfig.eslint.json tsconfig.json tsconfig.spec.json diff --git a/e2e/__tests__/ast-transformers.test.ts b/e2e/__tests__/ast-transformers.test.ts index a0608d11c9..338e3dc887 100644 --- a/e2e/__tests__/ast-transformers.test.ts +++ b/e2e/__tests__/ast-transformers.test.ts @@ -3,9 +3,7 @@ import path from 'path' import execa from 'execa' import { json as runWithJson } from '../run-jest' -import { runNpmInstall } from '../utils' - -const { createBundle } = require('../../scripts/lib/bundle') +import { runNpmInstall, tsJestBundle } from '../utils' const AST_TRANSFORMERS_DIR_NAME = 'ast-transformers' @@ -35,8 +33,7 @@ describe('path-mapping', () => { beforeAll(() => { runNpmInstall(DIR) - const bundle = createBundle() - execa.sync('npm', ['install', '--no-package-lock', '--no-shrinkwrap', '--no-save', bundle], { + execa.sync('npm', ['install', '--no-package-lock', '--no-shrinkwrap', '--no-save', tsJestBundle], { cwd: DIR, }) }) @@ -69,8 +66,7 @@ describe('hoist-jest', () => { beforeAll(() => { runNpmInstall(DIR) - const bundle = createBundle() - execa.sync('npm', ['install', '--no-package-lock', '--no-shrinkwrap', '--no-save', bundle], { + execa.sync('npm', ['install', '--no-package-lock', '--no-shrinkwrap', '--no-save', tsJestBundle], { cwd: DIR, }) }) diff --git a/e2e/__tests__/config-typing.test.ts b/e2e/__tests__/config-typing.test.ts index fae183bb45..46d8012a2e 100644 --- a/e2e/__tests__/config-typing.test.ts +++ b/e2e/__tests__/config-typing.test.ts @@ -1,7 +1,18 @@ +import path from 'path' + +import execa from 'execa' + import { json as runWithJson } from '../run-jest' +import { tsJestBundle } from '../utils' const DIR_NAME = 'config-typing' +beforeAll(() => { + execa.sync('npm', ['install', '--no-package-lock', '--no-shrinkwrap', '--no-save', tsJestBundle], { + cwd: path.join(__dirname, '..', DIR_NAME), + }) +}) + test(`successfully runs the tests inside ${DIR_NAME}`, () => { const { json } = runWithJson(DIR_NAME) diff --git a/e2e/__tests__/test-utils.test.ts b/e2e/__tests__/test-utils.test.ts index 91daf9a359..78b11d8373 100644 --- a/e2e/__tests__/test-utils.test.ts +++ b/e2e/__tests__/test-utils.test.ts @@ -1,7 +1,18 @@ +import path from 'path' + +import execa from 'execa' + import { json as runWithJson } from '../run-jest' +import { tsJestBundle } from '../utils' const DIR_NAME = 'test-utils' +beforeAll(() => { + execa.sync('npm', ['install', '--no-package-lock', '--no-shrinkwrap', '--no-save', tsJestBundle], { + cwd: path.join(__dirname, '..', DIR_NAME), + }) +}) + test(`successfully runs the tests inside ${DIR_NAME}`, () => { const { json } = runWithJson(DIR_NAME, undefined, { stripAnsi: true, diff --git a/e2e/ast-transformers/hoist-jest/non-ts-factory/jest-isolated.config.js b/e2e/ast-transformers/hoist-jest/non-ts-factory/jest-isolated.config.js index 86ea47ede6..502889e130 100644 --- a/e2e/ast-transformers/hoist-jest/non-ts-factory/jest-isolated.config.js +++ b/e2e/ast-transformers/hoist-jest/non-ts-factory/jest-isolated.config.js @@ -1,4 +1,4 @@ -/** @type {import('../../../dist/types').InitialOptionsTsJest} */ +/** @type {import('../../../../dist').InitialOptionsTsJest} */ module.exports = { automock: true, globals: { diff --git a/e2e/ast-transformers/hoist-jest/ts-factory/jest-isolated.config.js b/e2e/ast-transformers/hoist-jest/ts-factory/jest-isolated.config.js index 1d2f43f93e..5905849f93 100644 --- a/e2e/ast-transformers/hoist-jest/ts-factory/jest-isolated.config.js +++ b/e2e/ast-transformers/hoist-jest/ts-factory/jest-isolated.config.js @@ -1,4 +1,4 @@ -/** @type {import('../../../dist/types').InitialOptionsTsJest} */ +/** @type {import('../../../../dist').InitialOptionsTsJest} */ module.exports = { automock: true, globals: { diff --git a/e2e/ast-transformers/path-mapping/ts-4.5+/jest-isolated.config.js b/e2e/ast-transformers/path-mapping/ts-4.5+/jest-isolated.config.js index e856c37f46..cc869061b6 100644 --- a/e2e/ast-transformers/path-mapping/ts-4.5+/jest-isolated.config.js +++ b/e2e/ast-transformers/path-mapping/ts-4.5+/jest-isolated.config.js @@ -1,4 +1,4 @@ -/** @type {import('../../../../dist/types').InitialOptionsTsJest} */ +/** @type {import('../../../../dist').InitialOptionsTsJest} */ module.exports = { globals: { 'ts-jest': { diff --git a/e2e/ast-transformers/path-mapping/ts-4.5-/jest-isolated.config.js b/e2e/ast-transformers/path-mapping/ts-4.5-/jest-isolated.config.js index de1f70ba6e..a63340c04c 100644 --- a/e2e/ast-transformers/path-mapping/ts-4.5-/jest-isolated.config.js +++ b/e2e/ast-transformers/path-mapping/ts-4.5-/jest-isolated.config.js @@ -1,4 +1,4 @@ -/** @type {import('../../../../dist/types').InitialOptionsTsJest} */ +/** @type {import('../../../../dist').InitialOptionsTsJest} */ module.exports = { globals: { 'ts-jest': { diff --git a/e2e/ast-transformers/transformer-in-ts/package-lock.json b/e2e/ast-transformers/transformer-in-ts/package-lock.json deleted file mode 100644 index f174c47028..0000000000 --- a/e2e/ast-transformers/transformer-in-ts/package-lock.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "name": "ts-transformer", - "lockfileVersion": 2, - "requires": true, - "packages": { - "": { - "dependencies": { - "bs-logger": "^0.2.6" - } - }, - "node_modules/bs-logger": { - "version": "0.2.6", - "resolved": "https://registry.npmjs.org/bs-logger/-/bs-logger-0.2.6.tgz", - "integrity": "sha512-pd8DCoxmbgc7hyPKOvxtqNcjYoOsABPQdcCUjGp3d42VR2CX1ORhk2A87oqqu5R1kk+76nsxZupkmyd+MVtCog==", - "dependencies": { - "fast-json-stable-stringify": "2.x" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/fast-json-stable-stringify": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", - "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==" - } - }, - "dependencies": { - "bs-logger": { - "version": "0.2.6", - "resolved": "https://registry.npmjs.org/bs-logger/-/bs-logger-0.2.6.tgz", - "integrity": "sha512-pd8DCoxmbgc7hyPKOvxtqNcjYoOsABPQdcCUjGp3d42VR2CX1ORhk2A87oqqu5R1kk+76nsxZupkmyd+MVtCog==", - "requires": { - "fast-json-stable-stringify": "2.x" - } - }, - "fast-json-stable-stringify": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", - "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==" - } - } -} diff --git a/e2e/ast-transformers/transformer-options/jest-isolated.config.js b/e2e/ast-transformers/transformer-options/jest-isolated.config.js index 3710d2423e..763bbef262 100644 --- a/e2e/ast-transformers/transformer-options/jest-isolated.config.js +++ b/e2e/ast-transformers/transformer-options/jest-isolated.config.js @@ -1,4 +1,4 @@ -/** @type {import('../../../dist/types').InitialOptionsTsJest} */ +/** @type {import('../../../dist').InitialOptionsTsJest} */ module.exports = { globals: { 'ts-jest': { diff --git a/e2e/config-typing/__tests__/config-typing.spec.ts b/e2e/config-typing/__tests__/config-typing.spec.ts new file mode 100644 index 0000000000..a2cb31e766 --- /dev/null +++ b/e2e/config-typing/__tests__/config-typing.spec.ts @@ -0,0 +1,3 @@ +test('should expose TypeScript types for Jest config', () => { + expect(true).toBe(true) +}) diff --git a/e2e/config-typing/__tests__/jest-config-typing.spec.ts b/e2e/config-typing/__tests__/jest-config-typing.spec.ts deleted file mode 100644 index b8364e7e63..0000000000 --- a/e2e/config-typing/__tests__/jest-config-typing.spec.ts +++ /dev/null @@ -1,14 +0,0 @@ -import type { InitialOptionsTsJest } from '../../../dist/types' - -test('should expose TypeScript types for Jest config', () => { - const config: InitialOptionsTsJest = { - globals: { - 'ts-jest': { - isolatedModules: true, - }, - }, - verbose: true, - } - - expect(config).toBeTruthy() -}) diff --git a/e2e/config-typing/jest.config.ts b/e2e/config-typing/jest.config.ts new file mode 100644 index 0000000000..c63f43e6dc --- /dev/null +++ b/e2e/config-typing/jest.config.ts @@ -0,0 +1,14 @@ +import type { InitialOptionsTsJest } from 'ts-jest' + +const jestCfg: InitialOptionsTsJest = { + globals: { + 'ts-jest': { + isolatedModules: true, + }, + }, + transform: { + '^.+.tsx?$': 'ts-jest', + }, +} + +export default jestCfg diff --git a/e2e/config-typing/package-lock.json b/e2e/config-typing/package-lock.json new file mode 100644 index 0000000000..9bedfed0e3 --- /dev/null +++ b/e2e/config-typing/package-lock.json @@ -0,0 +1,251 @@ +{ + "name": "config-typing", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "dependencies": { + "ts-node": "^10.4.0" + } + }, + "node_modules/@cspotcode/source-map-consumer": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-consumer/-/source-map-consumer-0.8.0.tgz", + "integrity": "sha512-41qniHzTU8yAGbCp04ohlmSrZf8bkf/iJsl3V0dRGsQN/5GFfx+LbCSsCpp2gqrqjTVg/K6O8ycoV35JIwAzAg==", + "engines": { + "node": ">= 12" + } + }, + "node_modules/@cspotcode/source-map-support": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.7.0.tgz", + "integrity": "sha512-X4xqRHqN8ACt2aHVe51OxeA2HjbcL4MqFqXkrmQszJ1NOUuUu5u6Vqx/0lZSVNku7velL5FC/s5uEAj1lsBMhA==", + "dependencies": { + "@cspotcode/source-map-consumer": "0.8.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@tsconfig/node10": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.8.tgz", + "integrity": "sha512-6XFfSQmMgq0CFLY1MslA/CPUfhIL919M1rMsa5lP2P097N2Wd1sSX0tx1u4olM16fLNhtHZpRhedZJphNJqmZg==" + }, + "node_modules/@tsconfig/node12": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.9.tgz", + "integrity": "sha512-/yBMcem+fbvhSREH+s14YJi18sp7J9jpuhYByADT2rypfajMZZN4WQ6zBGgBKp53NKmqI36wFYDb3yaMPurITw==" + }, + "node_modules/@tsconfig/node14": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.1.tgz", + "integrity": "sha512-509r2+yARFfHHE7T6Puu2jjkoycftovhXRqW328PDXTVGKihlb1P8Z9mMZH04ebyajfRY7dedfGynlrFHJUQCg==" + }, + "node_modules/@tsconfig/node16": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.2.tgz", + "integrity": "sha512-eZxlbI8GZscaGS7kkc/trHTT5xgrjH3/1n2JDwusC9iahPKWMRvRjJSAN5mCXviuTGQ/lHnhvv8Q1YTpnfz9gA==" + }, + "node_modules/@types/node": { + "version": "16.11.9", + "license": "MIT", + "peer": true + }, + "node_modules/acorn": { + "version": "8.6.0", + "license": "MIT", + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/arg": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==" + }, + "node_modules/create-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", + "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==" + }, + "node_modules/diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "engines": { + "node": ">=0.3.1" + } + }, + "node_modules/make-error": { + "version": "1.3.6", + "license": "ISC" + }, + "node_modules/ts-node": { + "version": "10.4.0", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.4.0.tgz", + "integrity": "sha512-g0FlPvvCXSIO1JDF6S232P5jPYqBkRL9qly81ZgAOSU7rwI0stphCgd2kLiCrU9DjQCrJMWEqcNSjQL02s6d8A==", + "dependencies": { + "@cspotcode/source-map-support": "0.7.0", + "@tsconfig/node10": "^1.0.7", + "@tsconfig/node12": "^1.0.7", + "@tsconfig/node14": "^1.0.0", + "@tsconfig/node16": "^1.0.2", + "acorn": "^8.4.1", + "acorn-walk": "^8.1.1", + "arg": "^4.1.0", + "create-require": "^1.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "yn": "3.1.1" + }, + "bin": { + "ts-node": "dist/bin.js", + "ts-node-cwd": "dist/bin-cwd.js", + "ts-node-script": "dist/bin-script.js", + "ts-node-transpile-only": "dist/bin-transpile.js", + "ts-script": "dist/bin-script-deprecated.js" + }, + "peerDependencies": { + "@swc/core": ">=1.2.50", + "@swc/wasm": ">=1.2.50", + "@types/node": "*", + "typescript": ">=2.7" + }, + "peerDependenciesMeta": { + "@swc/core": { + "optional": true + }, + "@swc/wasm": { + "optional": true + } + } + }, + "node_modules/ts-node/node_modules/acorn-walk": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz", + "integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/typescript": { + "version": "4.5.2", + "license": "Apache-2.0", + "peer": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, + "node_modules/yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "engines": { + "node": ">=6" + } + } + }, + "dependencies": { + "@cspotcode/source-map-consumer": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-consumer/-/source-map-consumer-0.8.0.tgz", + "integrity": "sha512-41qniHzTU8yAGbCp04ohlmSrZf8bkf/iJsl3V0dRGsQN/5GFfx+LbCSsCpp2gqrqjTVg/K6O8ycoV35JIwAzAg==" + }, + "@cspotcode/source-map-support": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.7.0.tgz", + "integrity": "sha512-X4xqRHqN8ACt2aHVe51OxeA2HjbcL4MqFqXkrmQszJ1NOUuUu5u6Vqx/0lZSVNku7velL5FC/s5uEAj1lsBMhA==", + "requires": { + "@cspotcode/source-map-consumer": "0.8.0" + } + }, + "@tsconfig/node10": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.8.tgz", + "integrity": "sha512-6XFfSQmMgq0CFLY1MslA/CPUfhIL919M1rMsa5lP2P097N2Wd1sSX0tx1u4olM16fLNhtHZpRhedZJphNJqmZg==" + }, + "@tsconfig/node12": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.9.tgz", + "integrity": "sha512-/yBMcem+fbvhSREH+s14YJi18sp7J9jpuhYByADT2rypfajMZZN4WQ6zBGgBKp53NKmqI36wFYDb3yaMPurITw==" + }, + "@tsconfig/node14": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.1.tgz", + "integrity": "sha512-509r2+yARFfHHE7T6Puu2jjkoycftovhXRqW328PDXTVGKihlb1P8Z9mMZH04ebyajfRY7dedfGynlrFHJUQCg==" + }, + "@tsconfig/node16": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.2.tgz", + "integrity": "sha512-eZxlbI8GZscaGS7kkc/trHTT5xgrjH3/1n2JDwusC9iahPKWMRvRjJSAN5mCXviuTGQ/lHnhvv8Q1YTpnfz9gA==" + }, + "@types/node": { + "version": "16.11.9", + "peer": true + }, + "acorn": { + "version": "8.6.0" + }, + "arg": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==" + }, + "create-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", + "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==" + }, + "diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==" + }, + "make-error": { + "version": "1.3.6" + }, + "ts-node": { + "version": "10.4.0", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.4.0.tgz", + "integrity": "sha512-g0FlPvvCXSIO1JDF6S232P5jPYqBkRL9qly81ZgAOSU7rwI0stphCgd2kLiCrU9DjQCrJMWEqcNSjQL02s6d8A==", + "requires": { + "@cspotcode/source-map-support": "0.7.0", + "@tsconfig/node10": "^1.0.7", + "@tsconfig/node12": "^1.0.7", + "@tsconfig/node14": "^1.0.0", + "@tsconfig/node16": "^1.0.2", + "acorn": "^8.4.1", + "acorn-walk": "^8.1.1", + "arg": "^4.1.0", + "create-require": "^1.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "yn": "3.1.1" + }, + "dependencies": { + "acorn-walk": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz", + "integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==" + } + } + }, + "typescript": { + "version": "4.5.2", + "peer": true + }, + "yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==" + } + } +} diff --git a/e2e/config-typing/package.json b/e2e/config-typing/package.json index a2662c811c..0c79b2e5da 100644 --- a/e2e/config-typing/package.json +++ b/e2e/config-typing/package.json @@ -1,7 +1,5 @@ { - "jest": { - "transform": { - "^.+.tsx?$": "/../../dist/index.js" - } + "dependencies": { + "ts-node": "^10.4.0" } } diff --git a/e2e/const-enum/jest-isolated.config.js b/e2e/const-enum/jest-isolated.config.js index 3bdc3daa57..11cb510fe5 100644 --- a/e2e/const-enum/jest-isolated.config.js +++ b/e2e/const-enum/jest-isolated.config.js @@ -1,4 +1,4 @@ -/** @type {import('../../dist/types').InitialOptionsTsJest} */ +/** @type {import('../../dist').InitialOptionsTsJest} */ module.exports = { globals: { 'ts-jest': { diff --git a/e2e/coverage-report/jest-isolated.config.js b/e2e/coverage-report/jest-isolated.config.js index 6791be371f..2f557a6c8d 100644 --- a/e2e/coverage-report/jest-isolated.config.js +++ b/e2e/coverage-report/jest-isolated.config.js @@ -1,4 +1,4 @@ -/** @type {import('../../dist/types').InitialOptionsTsJest} */ +/** @type {import('../../dist').InitialOptionsTsJest} */ module.exports = { collectCoverageFrom: ['**/*.js', '**/*.ts', '!**/node_modules/**', '!**/coverage/**'], globals: { diff --git a/e2e/diagnostics/jest-disabled.config.js b/e2e/diagnostics/jest-disabled.config.js index c70a0a9143..daa9be25b7 100644 --- a/e2e/diagnostics/jest-disabled.config.js +++ b/e2e/diagnostics/jest-disabled.config.js @@ -1,4 +1,4 @@ -/** @type {import('../../dist/types').InitialOptionsTsJest} */ +/** @type {import('../../dist').InitialOptionsTsJest} */ module.exports = { globals: { 'ts-jest': { diff --git a/e2e/diagnostics/jest-exclude.config.js b/e2e/diagnostics/jest-exclude.config.js index 9fe7d1488e..abb3cb017d 100644 --- a/e2e/diagnostics/jest-exclude.config.js +++ b/e2e/diagnostics/jest-exclude.config.js @@ -1,4 +1,4 @@ -/** @type {import('../../dist/types').InitialOptionsTsJest} */ +/** @type {import('../../dist').InitialOptionsTsJest} */ module.exports = { globals: { 'ts-jest': { diff --git a/e2e/diagnostics/jest-ignored-code.config.js b/e2e/diagnostics/jest-ignored-code.config.js index 35b781d3d6..e4583808fa 100644 --- a/e2e/diagnostics/jest-ignored-code.config.js +++ b/e2e/diagnostics/jest-ignored-code.config.js @@ -1,4 +1,4 @@ -/** @type {import('../../dist/types').InitialOptionsTsJest} */ +/** @type {import('../../dist').InitialOptionsTsJest} */ module.exports = { globals: { 'ts-jest': { diff --git a/e2e/diagnostics/jest-isolated.config.js b/e2e/diagnostics/jest-isolated.config.js index 3bdc3daa57..11cb510fe5 100644 --- a/e2e/diagnostics/jest-isolated.config.js +++ b/e2e/diagnostics/jest-isolated.config.js @@ -1,4 +1,4 @@ -/** @type {import('../../dist/types').InitialOptionsTsJest} */ +/** @type {import('../../dist').InitialOptionsTsJest} */ module.exports = { globals: { 'ts-jest': { diff --git a/e2e/diagnostics/jest-warn.config.js b/e2e/diagnostics/jest-warn.config.js index 05049a0213..c4383858c9 100644 --- a/e2e/diagnostics/jest-warn.config.js +++ b/e2e/diagnostics/jest-warn.config.js @@ -1,4 +1,4 @@ -/** @type {import('../../dist/types').InitialOptionsTsJest} */ +/** @type {import('../../dist').InitialOptionsTsJest} */ module.exports = { globals: { 'ts-jest': { diff --git a/e2e/enum/jest-isolated.config.js b/e2e/enum/jest-isolated.config.js index 3bdc3daa57..11cb510fe5 100644 --- a/e2e/enum/jest-isolated.config.js +++ b/e2e/enum/jest-isolated.config.js @@ -1,4 +1,4 @@ -/** @type {import('../../dist/types').InitialOptionsTsJest} */ +/** @type {import('../../dist').InitialOptionsTsJest} */ module.exports = { globals: { 'ts-jest': { diff --git a/e2e/native-esm-ts/jest-isolated.config.js b/e2e/native-esm-ts/jest-isolated.config.js index 8d0f16bba5..6b069a7afe 100644 --- a/e2e/native-esm-ts/jest-isolated.config.js +++ b/e2e/native-esm-ts/jest-isolated.config.js @@ -1,4 +1,4 @@ -/** @type {import('../../dist/types').InitialOptionsTsJest} */ +/** @type {import('../../dist').InitialOptionsTsJest} */ module.exports = { extensionsToTreatAsEsm: ['.ts'], globals: { diff --git a/e2e/source-map/disabled/jest-isolated.config.js b/e2e/source-map/disabled/jest-isolated.config.js index 82c909e707..7691305a8f 100644 --- a/e2e/source-map/disabled/jest-isolated.config.js +++ b/e2e/source-map/disabled/jest-isolated.config.js @@ -1,4 +1,4 @@ -/** @type {import('../../../dist/types').InitialOptionsTsJest} */ +/** @type {import('../../../dist').InitialOptionsTsJest} */ module.exports = { displayName: 'sourcemap-disabled-isolated', roots: ['', '/../__tests__'], diff --git a/e2e/source-map/disabled/jest.config.js b/e2e/source-map/disabled/jest.config.js index 763da06114..865c88d8ca 100644 --- a/e2e/source-map/disabled/jest.config.js +++ b/e2e/source-map/disabled/jest.config.js @@ -1,4 +1,4 @@ -/** @type {import('../../../dist/types').InitialOptionsTsJest} */ +/** @type {import('../../../dist').InitialOptionsTsJest} */ module.exports = { displayName: 'sourcemap-disabled', roots: ['', '/../__tests__'], diff --git a/e2e/source-map/enabled/jest-isolated.config.js b/e2e/source-map/enabled/jest-isolated.config.js index 12a4e0f64f..b87431545b 100644 --- a/e2e/source-map/enabled/jest-isolated.config.js +++ b/e2e/source-map/enabled/jest-isolated.config.js @@ -1,4 +1,4 @@ -/** @type {import('../../../dist/types').InitialOptionsTsJest} */ +/** @type {import('../../../dist').InitialOptionsTsJest} */ module.exports = { displayName: 'sourcemap-enabled-isolated', roots: ['', '/../__tests__'], diff --git a/e2e/source-map/enabled/jest.config.js b/e2e/source-map/enabled/jest.config.js index 3cacc17844..736c67bc1f 100644 --- a/e2e/source-map/enabled/jest.config.js +++ b/e2e/source-map/enabled/jest.config.js @@ -1,4 +1,4 @@ -/** @type {import('../../../dist/types').InitialOptionsTsJest} */ +/** @type {import('../../../dist').InitialOptionsTsJest} */ module.exports = { displayName: 'sourcemap-enabled', roots: ['', '/../__tests__'], diff --git a/e2e/test-utils/__tests__/test-utils.spec.ts b/e2e/test-utils/__tests__/test-utils.spec.ts index be5dc4dbff..00f6aa208e 100644 --- a/e2e/test-utils/__tests__/test-utils.spec.ts +++ b/e2e/test-utils/__tests__/test-utils.spec.ts @@ -1,8 +1,25 @@ -import utils from '../../../utils' +import { mocked, createJestPreset, pathsToModuleNameMapper, MockedObject } from 'ts-jest' test('should expose mocked/createJestPreset/pathsToModuleNameMapper', () => { - expect(Object.keys(utils)).toEqual(['mocked', 'createJestPreset', 'pathsToModuleNameMapper']) - expect(typeof utils.mocked).toBe('function') - expect(typeof utils.createJestPreset).toBe('function') - expect(typeof utils.pathsToModuleNameMapper).toBe('function') + expect(typeof mocked).toBe('function') + expect(typeof createJestPreset).toBe('function') + expect(typeof pathsToModuleNameMapper).toBe('function') +}) + +test('should expose mock types', async () => { + interface SomeInterface { + validate(): boolean + } + const UserValidator: SomeInterface = { + validate: () => true, + } + async function someFunction() { + return [UserValidator] + } + + const mockedValidator: Array> = (await someFunction()).map((v: SomeInterface) => + mocked(v), + ) + + expect(mockedValidator).toBeDefined() }) diff --git a/e2e/transform-js/babel-enabled/jest.config.js b/e2e/transform-js/babel-enabled/jest.config.js index 5c8fecc8cf..ab6e5ebe4f 100644 --- a/e2e/transform-js/babel-enabled/jest.config.js +++ b/e2e/transform-js/babel-enabled/jest.config.js @@ -1,4 +1,4 @@ -/** @type {import('../../../dist/types').InitialOptionsTsJest} */ +/** @type {import('../../../dist').InitialOptionsTsJest} */ module.exports = { displayName: 'babel-enabled', roots: ['', '/../__tests__/for-babel'], diff --git a/e2e/transform-js/babel-file/jest.config.js b/e2e/transform-js/babel-file/jest.config.js index acc947b8ab..1bbf819fe6 100644 --- a/e2e/transform-js/babel-file/jest.config.js +++ b/e2e/transform-js/babel-file/jest.config.js @@ -1,4 +1,4 @@ -/** @type {import('../../../dist/types').InitialOptionsTsJest} */ +/** @type {import('../../../dist').InitialOptionsTsJest} */ module.exports = { displayName: 'babel-file', roots: ['', '/../__tests__/for-babel'], diff --git a/e2e/transform-js/no-type-check/jest.config.js b/e2e/transform-js/no-type-check/jest.config.js index 2e3c119fe8..0e81b1ea4d 100644 --- a/e2e/transform-js/no-type-check/jest.config.js +++ b/e2e/transform-js/no-type-check/jest.config.js @@ -1,4 +1,4 @@ -/** @type {import('../../../dist/types').InitialOptionsTsJest} */ +/** @type {import('../../../dist').InitialOptionsTsJest} */ module.exports = { displayName: 'no-type-check', roots: ['', '/../__tests__/for-ts'], diff --git a/e2e/transform-js/type-check/jest.config.js b/e2e/transform-js/type-check/jest.config.js index 8e0de936b7..a2579c2aba 100644 --- a/e2e/transform-js/type-check/jest.config.js +++ b/e2e/transform-js/type-check/jest.config.js @@ -1,4 +1,4 @@ -/** @type {import('../../../dist/types').InitialOptionsTsJest} */ +/** @type {import('../../../dist').InitialOptionsTsJest} */ module.exports = { displayName: 'type-check', roots: ['', '/../__tests__/for-ts'], diff --git a/e2e/transform-tsx/jest-isolated.config.js b/e2e/transform-tsx/jest-isolated.config.js index 61240583d6..5ddb63a8d5 100644 --- a/e2e/transform-tsx/jest-isolated.config.js +++ b/e2e/transform-tsx/jest-isolated.config.js @@ -1,4 +1,4 @@ -/** @type {import('../../dist/types').InitialOptionsTsJest} */ +/** @type {import('../../dist').InitialOptionsTsJest} */ module.exports = { globals: { 'ts-jest': { diff --git a/e2e/utils.ts b/e2e/utils.ts index 12b79c84bc..0882ce1d30 100644 --- a/e2e/utils.ts +++ b/e2e/utils.ts @@ -4,6 +4,10 @@ import type { Config } from '@jest/types' import { ExecaReturnValue, sync as spawnSync } from 'execa' import * as fs from 'graceful-fs' +import { version } from '../package.json' + +export const tsJestBundle = path.join(__dirname, '..', `ts-jest-${version}.tgz`) + interface RunResult extends ExecaReturnValue { status: number error: Error diff --git a/examples/js-with-babel/jest-esm-isolated.config.js b/examples/js-with-babel/jest-esm-isolated.config.js new file mode 100644 index 0000000000..f1a90621c5 --- /dev/null +++ b/examples/js-with-babel/jest-esm-isolated.config.js @@ -0,0 +1,12 @@ +/** @type {import('ts-jest').InitialOptionsTsJest} */ +module.exports = { + preset: 'ts-jest/presets/js-with-babel-esm', + globals: { + 'ts-jest': { + babelConfig: true, + isolatedModules: true, + tsconfig: 'tsconfig-esm.json', + useESM: true, + }, + }, +} diff --git a/examples/js-with-babel/jest-esm.config.js b/examples/js-with-babel/jest-esm.config.js index 9ea834dcd5..230fcae773 100644 --- a/examples/js-with-babel/jest-esm.config.js +++ b/examples/js-with-babel/jest-esm.config.js @@ -1,4 +1,4 @@ -/** @type {import('@jest/types').Config.InitialOptions} */ +/** @type {import('ts-jest').InitialOptionsTsJest} */ module.exports = { preset: 'ts-jest/presets/js-with-babel-esm', globals: { diff --git a/examples/js-with-babel/jest-isolated.config.js b/examples/js-with-babel/jest-isolated.config.js new file mode 100644 index 0000000000..12c530644c --- /dev/null +++ b/examples/js-with-babel/jest-isolated.config.js @@ -0,0 +1,10 @@ +/** @type {import('ts-jest').InitialOptionsTsJest} */ +module.exports = { + preset: 'ts-jest/presets/js-with-babel', + globals: { + 'ts-jest': { + babelConfig: true, + isolatedModules: true, + }, + }, +} diff --git a/examples/js-with-babel/jest.config.js b/examples/js-with-babel/jest.config.js index 290381f074..2a54960583 100644 --- a/examples/js-with-babel/jest.config.js +++ b/examples/js-with-babel/jest.config.js @@ -1,4 +1,4 @@ -/** @type {import('@jest/types').Config.InitialOptions} */ +/** @type {import('ts-jest').InitialOptionsTsJest} */ module.exports = { preset: 'ts-jest/presets/js-with-babel', globals: { diff --git a/examples/js-with-babel/package.json b/examples/js-with-babel/package.json index 7efe413a12..d90e51e85a 100644 --- a/examples/js-with-babel/package.json +++ b/examples/js-with-babel/package.json @@ -2,8 +2,10 @@ "name": "js-with-babel", "version": "0.0.0", "scripts": { - "test": "jest", - "test-esm": "node --experimental-vm-modules --no-warnings node_modules/jest/bin/jest.js -c=jest-esm.config.js" + "test": "jest --no-cache", + "test-isolated": "jest -c=jest-isolated.config.js --no-cache", + "test-esm": "node --experimental-vm-modules --no-warnings node_modules/jest/bin/jest.js -c=jest-esm.config.js --no-cache", + "test-esm-isolated": "node --experimental-vm-modules --no-warnings node_modules/jest/bin/jest.js -c=jest-esm-isolated.config.js --no-cache" }, "devDependencies": { "@babel/core": "^7.16.0", diff --git a/examples/js-with-ts/jest-esm-isolated.config.js b/examples/js-with-ts/jest-esm-isolated.config.js new file mode 100644 index 0000000000..2bf1f5c4a1 --- /dev/null +++ b/examples/js-with-ts/jest-esm-isolated.config.js @@ -0,0 +1,11 @@ +/** @type {import('ts-jest').InitialOptionsTsJest} */ +module.exports = { + preset: 'ts-jest/presets/js-with-ts-esm', + globals: { + 'ts-jest': { + isolatedModules: true, + tsconfig: 'tsconfig-esm.json', + useESM: true, + }, + }, +} diff --git a/examples/js-with-ts/jest-esm.config.js b/examples/js-with-ts/jest-esm.config.js index 148a0437c0..594590d1cb 100644 --- a/examples/js-with-ts/jest-esm.config.js +++ b/examples/js-with-ts/jest-esm.config.js @@ -1,4 +1,4 @@ -/** @type {import('@jest/types').Config.InitialOptions} */ +/** @type {import('ts-jest').InitialOptionsTsJest} */ module.exports = { preset: 'ts-jest/presets/js-with-ts-esm', globals: { diff --git a/examples/js-with-ts/jest-isolated.config.js b/examples/js-with-ts/jest-isolated.config.js new file mode 100644 index 0000000000..241040d822 --- /dev/null +++ b/examples/js-with-ts/jest-isolated.config.js @@ -0,0 +1,9 @@ +/** @type {import('ts-jest').InitialOptionsTsJest} */ +module.exports = { + preset: 'ts-jest/presets/js-with-ts', + globals: { + 'ts-jest': { + isolatedModules: true, + }, + }, +} diff --git a/examples/js-with-ts/jest.config.js b/examples/js-with-ts/jest.config.js index 26c1acd60d..9e59e68f8c 100644 --- a/examples/js-with-ts/jest.config.js +++ b/examples/js-with-ts/jest.config.js @@ -1,4 +1,4 @@ -/** @type {import('@jest/types').Config.InitialOptions} */ +/** @type {import('ts-jest').InitialOptionsTsJest} */ module.exports = { preset: 'ts-jest/presets/js-with-ts', } diff --git a/examples/js-with-ts/package.json b/examples/js-with-ts/package.json index 9b103e963e..a6e87a4e83 100644 --- a/examples/js-with-ts/package.json +++ b/examples/js-with-ts/package.json @@ -2,8 +2,10 @@ "name": "js-with-ts", "version": "0.0.0", "scripts": { - "test": "jest", - "test-esm": "node --experimental-vm-modules --no-warnings node_modules/jest/bin/jest.js -c=jest-esm.config.js" + "test": "jest --no-cache", + "test-isolated": "jest -c=jest-isolated.config.js --no-cache", + "test-esm": "node --experimental-vm-modules --no-warnings node_modules/jest/bin/jest.js -c=jest-esm.config.js --no-cache", + "test-esm-isolated": "node --experimental-vm-modules --no-warnings node_modules/jest/bin/jest.js -c=jest-esm-isolated.config.js --no-cache" }, "devDependencies": { "@types/jest": "^27.0.2", diff --git a/examples/ts-only/jest-esm-isolated.config.js b/examples/ts-only/jest-esm-isolated.config.js new file mode 100644 index 0000000000..44448189af --- /dev/null +++ b/examples/ts-only/jest-esm-isolated.config.js @@ -0,0 +1,11 @@ +/** @type {import('ts-jest').InitialOptionsTsJest} */ +module.exports = { + preset: 'ts-jest/presets/default-esm', + globals: { + 'ts-jest': { + isolatedModules: true, + tsconfig: 'tsconfig-esm.json', + useESM: true, + }, + }, +} diff --git a/examples/ts-only/jest-esm.config.js b/examples/ts-only/jest-esm.config.js index d6aaa2d628..54ad7d58de 100644 --- a/examples/ts-only/jest-esm.config.js +++ b/examples/ts-only/jest-esm.config.js @@ -1,4 +1,4 @@ -/** @type {import('@jest/types').Config.InitialOptions} */ +/** @type {import('ts-jest').InitialOptionsTsJest} */ module.exports = { preset: 'ts-jest/presets/default-esm', globals: { diff --git a/examples/ts-only/jest-isolated.config.js b/examples/ts-only/jest-isolated.config.js new file mode 100644 index 0000000000..828e02c34e --- /dev/null +++ b/examples/ts-only/jest-isolated.config.js @@ -0,0 +1,9 @@ +/** @type {import('ts-jest').InitialOptionsTsJest} */ +module.exports = { + preset: 'ts-jest', + globals: { + 'ts-jest': { + isolatedModules: true, + }, + }, +} diff --git a/examples/ts-only/jest.config.js b/examples/ts-only/jest.config.js index fabc8adb69..8f40d8b712 100644 --- a/examples/ts-only/jest.config.js +++ b/examples/ts-only/jest.config.js @@ -1,4 +1,4 @@ -/** @type {import('@jest/types').Config.InitialOptions} */ +/** @type {import('ts-jest').InitialOptionsTsJest} */ module.exports = { preset: 'ts-jest', } diff --git a/examples/ts-only/package.json b/examples/ts-only/package.json index d23611ddec..7477f07219 100644 --- a/examples/ts-only/package.json +++ b/examples/ts-only/package.json @@ -2,8 +2,10 @@ "name": "ts-only", "version": "0.0.0", "scripts": { - "test": "jest", - "test-esm": "node --experimental-vm-modules --no-warnings node_modules/jest/bin/jest.js -c=jest-esm.config.js" + "test": "jest --no-cache", + "test-isolated": "jest -c=jest-isolated.config.js --no-cache", + "test-esm": "node --experimental-vm-modules --no-warnings node_modules/jest/bin/jest.js -c=jest-esm.config.js --no-cache", + "test-esm-isolated": "node --experimental-vm-modules --no-warnings node_modules/jest/bin/jest.js -c=jest-esm-isolated.config.js --no-cache" }, "devDependencies": { "@types/jest": "^27.0.2", diff --git a/jest.config.js b/jest.config.js index 4e1577d6d4..f4d9d36a3e 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,4 +1,4 @@ -/** @type {import('./dist/types').InitialOptionsTsJest} */ +/** @type {import('./dist').InitialOptionsTsJest} */ module.exports = { globals: { 'ts-jest': { diff --git a/package.json b/package.json index d7de59ff97..1b941d10d4 100644 --- a/package.json +++ b/package.json @@ -11,9 +11,8 @@ "prebuild": "rimraf dist coverage *.tgz", "build": "tsc -p tsconfig.build.json", "postbuild": "node scripts/post-build.js", - "pretest": "tsc -p tsconfig.spec.json --noEmit", - "test": "jest -i", - "test-ci": "jest", + "pretest": "tsc -p tsconfig.spec.json --noEmit && node scripts/prepare-test.js", + "test": "jest", "test-examples": "node scripts/test-examples.js", "lint": "node_modules/.bin/eslint --ext .js,.ts .", "lint-fix": "node_modules/.bin/eslint --fix --ext .js,.ts .", diff --git a/presets/index.d.ts b/presets/index.d.ts index ddaaddc521..c61abe9dd8 100644 --- a/presets/index.d.ts +++ b/presets/index.d.ts @@ -1,4 +1,4 @@ -import type { TsJestPresets } from '../dist/types' +import type { TsJestPresets } from '../dist' declare const _default: { defaults: TsJestPresets; diff --git a/scripts/prepare-test.js b/scripts/prepare-test.js new file mode 100644 index 0000000000..271d529834 --- /dev/null +++ b/scripts/prepare-test.js @@ -0,0 +1,3 @@ +const { createBundle } = require('./lib/bundle') + +createBundle() diff --git a/scripts/test-examples.js b/scripts/test-examples.js index d3802edddb..30def49892 100755 --- a/scripts/test-examples.js +++ b/scripts/test-examples.js @@ -32,12 +32,15 @@ const executeTest = (projectPath) => { logger.log() execa.sync('npm', ['install', '--no-package-lock', '--no-shrinkwrap', '--no-save', bundle], { cwd: projectPath }) + logger.log() // then we can run the tests - const cmdLine = ['npm', 'run', 'test', '--', '--no-cache'] - const cmdESMLine = ['npm', 'run', 'test-esm', '--', '--no-cache'] + const cmdLine = ['npm', 'run', 'test'] + const cmdIsolatedLine = ['npm', 'run', 'test-isolated'] + const cmdESMLine = ['npm', 'run', 'test-esm'] + const cmdESMIsolatedLine = ['npm', 'run', 'test-esm-isolated'] - logger.log('starting the CommonJS tests using:', ...cmdLine) + logger.log('starting the CommonJS tests with `isolatedModules: false` using:', ...cmdLine) logger.log() execa.sync(cmdLine.shift(), cmdLine, { @@ -45,8 +48,19 @@ const executeTest = (projectPath) => { stdio: 'inherit', env: process.env, }) + logger.log() + + logger.log('starting the CommonJS tests with `isolatedModules: true` using:', ...cmdIsolatedLine) + logger.log() + + execa.sync(cmdIsolatedLine.shift(), cmdIsolatedLine, { + cwd: projectPath, + stdio: 'inherit', + env: process.env, + }) + logger.log() - logger.log('starting the ESM tests using:', ...cmdESMLine) + logger.log('starting the ESM tests with `isolatedModules: false` using:', ...cmdESMLine) logger.log() execa.sync(cmdESMLine.shift(), cmdESMLine, { @@ -54,6 +68,17 @@ const executeTest = (projectPath) => { stdio: 'inherit', env: process.env, }) + logger.log() + + logger.log('starting the ESM tests with `isolatedModules: true` using:', ...cmdESMIsolatedLine) + logger.log() + + execa.sync(cmdESMIsolatedLine.shift(), cmdESMIsolatedLine, { + cwd: projectPath, + stdio: 'inherit', + env: process.env, + }) + logger.log() } exampleAppsToRun.forEach((projectPath) => { diff --git a/src/compiler/index.ts b/src/compiler/index.ts new file mode 100644 index 0000000000..acccd5fab2 --- /dev/null +++ b/src/compiler/index.ts @@ -0,0 +1,3 @@ +export * from './compiler-utils' +export * from './ts-compiler' +export * from './ts-jest-compiler' diff --git a/src/config/index.ts b/src/config/index.ts new file mode 100644 index 0000000000..c160ca4257 --- /dev/null +++ b/src/config/index.ts @@ -0,0 +1,2 @@ +export * from './config-set' +export * from './paths-to-module-name-mapper' diff --git a/src/index.ts b/src/index.ts index 9cfb6e5d73..0b329a439c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,14 @@ import { TsJestTransformer } from './ts-jest-transformer' +export * from './constants' +export * from './compiler' +export * from './config' +export * from './presets/create-jest-preset' +export * from './utils' +export * from './raw-compiler-options' +export * from './ts-jest-transformer' +export * from './types' + export default { createTransformer: (): TsJestTransformer => new TsJestTransformer(), } diff --git a/src/types.ts b/src/types.ts index 87a309ed17..ebd8c22238 100644 --- a/src/types.ts +++ b/src/types.ts @@ -3,7 +3,7 @@ import type { Config } from '@jest/types' import type * as _babel from 'babel__core' import type * as _ts from 'typescript' -import type { ConfigSet } from './config/config-set' +import type { ConfigSet } from './config' import type { RawCompilerOptions } from './raw-compiler-options' declare module '@jest/types' { diff --git a/src/utils/index.spec.ts b/src/utils/index.spec.ts new file mode 100644 index 0000000000..7c46bfb3c7 --- /dev/null +++ b/src/utils/index.spec.ts @@ -0,0 +1,9 @@ +test('should show warning when importing from `ts-jest/utils`', async () => { + console.warn = jest.fn() + + await import('../../utils') + + expect(console.warn).toHaveBeenCalledWith( + 'ts-jest[main] (WARN) Replace any occurrences of "ts-jest/utils" with just "ts-jest".', + ) +}) diff --git a/src/utils/index.ts b/src/utils/index.ts new file mode 100644 index 0000000000..7e88f417d3 --- /dev/null +++ b/src/utils/index.ts @@ -0,0 +1,4 @@ +export * from './json' +export * from './jsonable-value' +export * from './logger' +export * from './testing' diff --git a/utils/index.js b/utils/index.js index 48929af5bc..749ab42029 100644 --- a/utils/index.js +++ b/utils/index.js @@ -2,6 +2,8 @@ const { pathsToModuleNameMapper } = require('../dist/config/paths-to-module-name const { createJestPreset } = require('../dist/presets/create-jest-preset') const { mocked } = require('../dist/utils/testing') +console.warn('ts-jest[main] (WARN) Replace any occurrences of "ts-jest/utils" with just "ts-jest".') + module.exports = { get mocked() { return mocked diff --git a/website/docs/getting-started/options.md b/website/docs/getting-started/options.md index 50518e7535..a5c8784da8 100644 --- a/website/docs/getting-started/options.md +++ b/website/docs/getting-started/options.md @@ -41,7 +41,7 @@ module.exports = { To utilize IDE suggestions, you can use `JSDoc` comments to provide suggested `ts-jest` configs for your Jest config: ```js -/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ +/** @type {import('ts-jest').InitialOptionsTsJest} */ module.exports = config = { // [...] globals: { @@ -58,7 +58,7 @@ Or through TypeScript (if `ts-node` is installed): ```ts // jest.config.ts -import type { InitialOptionsTsJest } from 'ts-jest/dist/types' +import type { InitialOptionsTsJest } from 'ts-jest' const config: InitialOptionsTsJest = { globals: { @@ -96,7 +96,6 @@ All options have default values which should fit most of the projects. Click on [tsconfig]: options/tsconfig [isolatedmodules]: options/isolatedModules [asttransformers]: options/astTransformers -[compilerhost]: options/compilerHost [diagnostics]: options/diagnostics [babelconfig]: options/babelConfig [stringifycontentpathregex]: options/stringifyContentPathRegex diff --git a/website/docs/getting-started/paths-mapping.md b/website/docs/getting-started/paths-mapping.md index 57509373b2..f928f534d9 100644 --- a/website/docs/getting-started/paths-mapping.md +++ b/website/docs/getting-started/paths-mapping.md @@ -56,7 +56,7 @@ module.exports = { ```js // jest.config.js -const { pathsToModuleNameMapper } = require('ts-jest/utils') +const { pathsToModuleNameMapper } = require('ts-jest') // In the following statement, replace `./tsconfig` with the path to your `tsconfig` file // which contains the path mapping (ie the `compilerOptions.paths` option): const { compilerOptions } = require('./tsconfig') diff --git a/website/docs/getting-started/presets.md b/website/docs/getting-started/presets.md index c7bfc5d8ca..be43edb499 100644 --- a/website/docs/getting-started/presets.md +++ b/website/docs/getting-started/presets.md @@ -73,7 +73,7 @@ Or through TypeScript (if `ts-node` is installed): ```ts // jest.config.ts -import type { InitialOptionsTsJest } from 'ts-jest/dist/types' +import type { InitialOptionsTsJest } from 'ts-jest' import { defaults as tsjPreset } from 'ts-jest/presets' // import { defaultsESM as tsjPreset } from 'ts-jest/presets' // import { jsWithTs as tsjPreset } from 'ts-jest/presets' diff --git a/website/docs/guides/test-helpers.md b/website/docs/guides/test-helpers.md index cab5788c6c..23f511606b 100644 --- a/website/docs/guides/test-helpers.md +++ b/website/docs/guides/test-helpers.md @@ -29,7 +29,7 @@ export const foo = { ```ts // foo.spec.ts -import { mocked } from 'ts-jest/utils' +import { mocked } from 'ts-jest' import { foo } from './foo' jest.mock('./foo') diff --git a/website/versioned_docs/version-26.5/getting-started/options.md b/website/versioned_docs/version-26.5/getting-started/options.md index ef4ff8cc6f..2448614049 100644 --- a/website/versioned_docs/version-26.5/getting-started/options.md +++ b/website/versioned_docs/version-26.5/getting-started/options.md @@ -72,7 +72,6 @@ All options have default values which should fit most of the projects. Click on [tsconfig]: options/tsconfig [isolatedmodules]: options/isolatedModules [asttransformers]: options/astTransformers -[compilerhost]: options/compilerHost [diagnostics]: options/diagnostics [babelconfig]: options/babelConfig [stringifycontentpathregex]: options/stringifyContentPathRegex diff --git a/website/versioned_docs/version-27.0/getting-started/options.md b/website/versioned_docs/version-27.0/getting-started/options.md index 50518e7535..f4f024cded 100644 --- a/website/versioned_docs/version-27.0/getting-started/options.md +++ b/website/versioned_docs/version-27.0/getting-started/options.md @@ -96,7 +96,6 @@ All options have default values which should fit most of the projects. Click on [tsconfig]: options/tsconfig [isolatedmodules]: options/isolatedModules [asttransformers]: options/astTransformers -[compilerhost]: options/compilerHost [diagnostics]: options/diagnostics [babelconfig]: options/babelConfig [stringifycontentpathregex]: options/stringifyContentPathRegex