Skip to content

Commit

Permalink
feat: export ts-jest public apis from index.js (#3080)
Browse files Browse the repository at this point in the history
Closes #3045 

DEPRECATION
* Import internal `ts-jest` stuffs from `ts-jest/<sub_path>` is discouraged. Users should switch to `import <name> from 'ts-jest'` instead.

* Deprecation import path `import <name> from 'ts-jest/utils'`. Users should switch to `import <name> from 'ts-jest'` instead.
  • Loading branch information
ahnpnl authored Nov 19, 2021
1 parent 6575fe2 commit 53175dd
Show file tree
Hide file tree
Showing 70 changed files with 497 additions and 133 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 0 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jest-base.js

# Tsconfig
tsconfig.build.json
tsconfig.eslint.json
tsconfig.json
tsconfig.spec.json

Expand Down
10 changes: 3 additions & 7 deletions e2e/__tests__/ast-transformers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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,
})
})
Expand Down Expand Up @@ -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,
})
})
Expand Down
11 changes: 11 additions & 0 deletions e2e/__tests__/config-typing.test.ts
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
11 changes: 11 additions & 0 deletions e2e/__tests__/test-utils.test.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @type {import('../../../dist/types').InitialOptionsTsJest} */
/** @type {import('../../../../dist').InitialOptionsTsJest} */
module.exports = {
automock: true,
globals: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @type {import('../../../dist/types').InitialOptionsTsJest} */
/** @type {import('../../../../dist').InitialOptionsTsJest} */
module.exports = {
automock: true,
globals: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @type {import('../../../../dist/types').InitialOptionsTsJest} */
/** @type {import('../../../../dist').InitialOptionsTsJest} */
module.exports = {
globals: {
'ts-jest': {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @type {import('../../../../dist/types').InitialOptionsTsJest} */
/** @type {import('../../../../dist').InitialOptionsTsJest} */
module.exports = {
globals: {
'ts-jest': {
Expand Down
43 changes: 0 additions & 43 deletions e2e/ast-transformers/transformer-in-ts/package-lock.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @type {import('../../../dist/types').InitialOptionsTsJest} */
/** @type {import('../../../dist').InitialOptionsTsJest} */
module.exports = {
globals: {
'ts-jest': {
Expand Down
3 changes: 3 additions & 0 deletions e2e/config-typing/__tests__/config-typing.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
test('should expose TypeScript types for Jest config', () => {
expect(true).toBe(true)
})
14 changes: 0 additions & 14 deletions e2e/config-typing/__tests__/jest-config-typing.spec.ts

This file was deleted.

14 changes: 14 additions & 0 deletions e2e/config-typing/jest.config.ts
Original file line number Diff line number Diff line change
@@ -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
Loading

0 comments on commit 53175dd

Please sign in to comment.