Skip to content

Commit

Permalink
Merge pull request #626 from huafu/feature/upgrade-babel-and-fix-tsco…
Browse files Browse the repository at this point in the history
…nfig

upgrade deps - coverage, caching and source-mapping fixes, ...
  • Loading branch information
kulshekhar committed Aug 2, 2018
2 parents c67ba4d + ef21f50 commit 9e61969
Show file tree
Hide file tree
Showing 94 changed files with 1,887 additions and 1,485 deletions.
24 changes: 0 additions & 24 deletions .github/ISSUE_TEMPLATE

This file was deleted.

20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE.md
@@ -0,0 +1,20 @@
<!-- First of all, check the troubleshooting wiki page for common issues at:
https://github.com/kulshekhar/ts-jest/wiki/Troubleshooting -->

## Issue <!-- describe the issue below -->:


## Expected behavior <!-- describe the expected behavior below -->:


## Output from debug log <!-- You can activate the debug logger by setting the environment variable TS_JEST_DEBUG="true" before running yarn test. The output of the logger will be in **<your_project_dir>/node_modules/ts-jest/debug.txt**, paste it below -->:
```bash
# content of debug.txt :

```


## Minimal repo <!-- If you haven't already, create the smallest possible repo that reproduces this issue by running `npm install` and `npm test`. This will speed up any fixes that this issue might need. Paste the minimal repo URL below -->:


<!-- Optional (but highly recommended): Configure Travis (or your favorite system) with the minimal repo. This allows potential solutions to be tested against the minimal repo. This saves everyone time and avoids a lot of back and forth. -->
5 changes: 4 additions & 1 deletion COLLABORATORS.md
@@ -1,11 +1,14 @@
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*
**Table of Contents**

- [Collaborator Guidelines](#collaborator-guidelines)
- [Installing and building the project](#installing-and-building-the-project)
- [Merging PRs](#merging-prs)
- [Versioning](#versioning)
- [Tests](#tests)
- [How to add tests](#how-to-add-tests)
- [How to run tests](#how-to-run-tests)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

Expand Down
15 changes: 4 additions & 11 deletions README.md
@@ -1,17 +1,11 @@
# ts-jest
# ts-jest [![npm version](https://badge.fury.io/js/ts-jest.svg)](https://badge.fury.io/js/ts-jest) [![NPM downloads](https://img.shields.io/npm/dm/ts-jest.svg?style=flat)](https://npmjs.org/package/ts-jest) [![Greenkeeper badge](https://badges.greenkeeper.io/kulshekhar/ts-jest.svg)](https://greenkeeper.io/) [![Build Status for linux](https://travis-ci.org/kulshekhar/ts-jest.svg?branch=master)](https://travis-ci.org/kulshekhar/ts-jest) [![Build Status for Windows](https://ci.appveyor.com/api/projects/status/g8tt9qd7usv0tolb/branch/master?svg=true)](https://ci.appveyor.com/project/kulshekhar/ts-jest/branch/master)

[![npm version](https://badge.fury.io/js/ts-jest.svg)](https://badge.fury.io/js/ts-jest)
[![NPM downloads](https://img.shields.io/npm/dm/ts-jest.svg?style=flat)](https://npmjs.org/package/ts-jest)
[![Greenkeeper badge](https://badges.greenkeeper.io/kulshekhar/ts-jest.svg)](https://greenkeeper.io/)
**Important note**: Before reporting any issue, be sure to check the [troubleshooting page](https://github.com/kulshekhar/ts-jest/wiki/Troubleshooting).

[![Build Status for linux](https://travis-ci.org/kulshekhar/ts-jest.svg?branch=master)](https://travis-ci.org/kulshekhar/ts-jest)
[![Build Status for Windows](https://ci.appveyor.com/api/projects/status/g8tt9qd7usv0tolb/branch/master?svg=true)](https://ci.appveyor.com/project/kulshekhar/ts-jest/branch/master)

**Important note: When using React 16 with Node version 8, you might see wrong line numbers for errors originating from tsx files. There's [an issue with more details on this](https://github.com/kulshekhar/ts-jest/issues/334)**

> Note: Looking for collaborators. [Want to help improve ts-jest?](https://github.com/kulshekhar/ts-jest/issues/223)
ts-jest is a TypeScript preprocessor with source map support for Jest that lets you use Jest to test projects written in TypeScript.
**ts-jest** is a TypeScript preprocessor with source map support for Jest that lets you use Jest to test projects written in TypeScript.

## Table of Contents
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
Expand Down Expand Up @@ -233,7 +227,7 @@ In some cases, projects may not want to have a `.babelrc` file, but still need t
"globals": {
"ts-jest": {
"babelConfig": {
"presets": ["env"]
"presets": ["@babel/env"]
}
}
}
Expand Down Expand Up @@ -404,7 +398,6 @@ By default Jest ignores everything in `node_modules`. This setting prevents Jest
## Known Limitations
### Known limitations for TS compiler options
- You can't use `"target": "ES6"` while using `node v4` in your test environment;
- You can't use `"jsx": "preserve"` for now (see [progress of this issue](https://github.com/kulshekhar/ts-jest/issues/63));
- If you use `"baseUrl": "<path_to_your_sources>"`, you also have to change `jest config` a little bit (also check [Module path mapping](#module-path-mapping) section):
```json
"jest": {
Expand Down
11 changes: 0 additions & 11 deletions index.d.ts

This file was deleted.

15 changes: 0 additions & 15 deletions index.js

This file was deleted.

47 changes: 27 additions & 20 deletions package.json
@@ -1,18 +1,18 @@
{
"name": "ts-jest",
"version": "23.0.1",
"main": "index.js",
"main": "dist/index.js",
"types": "./dist/index.d.ts",
"description": "A preprocessor with sourcemap support to help use Typescript with Jest",
"scripts": {
"build": "cpx index.d.ts dist/ && tsc -p .",
"build:watch": "cpx index.d.ts dist/ && tsc -p . -w",
"test:nolint": "npm run clean-build && node scripts/tests.js",
"clean": "rimraf dist/**/* && rimraf tests/simple/coverage && rimraf tests/simple-async/coverage && rimraf tests/**/*/debug.txt && rimraf tests/**/node_modules",
"build": "tsc -p tsconfig.build.json",
"build:watch": "tsc -p tsconfig.build.json -w",
"test:nolint": "npm run clean-build && jest --clearCache && node scripts/tests.js",
"clean": "rimraf dist/**/* && rimraf tests/*/coverage && rimraf tests/*/debug.txt && rimraf tests/*/node_modules",
"clean-build": "npm run clean && npm run build",
"pretest": "npm run tslint && npm run clean-build",
"test": "node scripts/tests.js",
"tslint": "tslint src/*.ts",
"tslint": "tslint 'src/**/*.ts'",
"doc": "doctoc .",
"prepublish": "npm run clean-build",
"precommit": "lint-staged",
Expand All @@ -38,7 +38,7 @@
"homepage": "https://github.com/kulshekhar/ts-jest#readme",
"jest": {
"transform": {
"^.+\\.tsx?$": "<rootDir>/dist/preprocessor.js"
"^.+\\.tsx?$": "<rootDir>/dist/index.js"
},
"testRegex": "tests/__tests__/.*\\.spec\\.ts$",
"testPathIgnorePatterns": [
Expand All @@ -59,47 +59,54 @@
"js",
"jsx",
"json"
]
],
"globals": {
"ts-jest": {
"tsConfigFile": "tsconfig.base.json"
}
}
},
"dependencies": {
"babel-plugin-istanbul": "^4.1.6",
"babel-preset-jest": "^23.0.0",
"closest-file-data": "^0.1.4",
"fs-extra": "6.0.1",
"lodash": "^4.17.10"
},
"peerDependencies": {
"babel-core": "^6.26.3 || ^7.0.0-0",
"babel-core": "^6.0.0 || ^7.0.0-0",
"babel-jest": "^23.0.0 || ^24.0.0",
"jest": "^23.0.0 || ^24.0.0",
"typescript": "^2.0.0 || ^3.0.0"
},
"devDependencies": {
"@types/babel-core": "latest",
"@babel/core": "^7.0.0-beta.54",
"@babel/preset-env": "^7.0.0-beta.54",
"@types/babel-core": "^6.25.5",
"@types/es6-shim": "0.31.37",
"@types/fs-extra": "5.0.4",
"@types/jest": "^23.1.0",
"@types/jest": "^23.3.0",
"@types/lodash": "^4.14.109",
"@types/node": "10.5.5",
"@types/react": "16.4.7",
"@types/yargs": "^11.0.0",
"babel-core": "^6.26.3",
"babel-preset-env": "^1.7.0",
"babel-jest": "^23.4.0",
"babel-preset-jest": "^23.2.0",
"babel-core": "^7.0.0-0",
"cpx": "^1.5.0",
"cross-spawn": "latest",
"cross-spawn-with-kill": "latest",
"doctoc": "latest",
"husky": "^0.14.3",
"jest": "^23.0.0",
"jest-config": "^23.0.0",
"jest": "^23.4.1",
"jest-config": "^23.4.1",
"lint-staged": "^7.1.2",
"pkg-dir": "^3.0.0",
"prettier": "^1.12.1",
"react": "16.4.2",
"react-test-renderer": "16.4.2",
"reflect-metadata": "^0.1.12",
"rimraf": "^2.6.2",
"ts-jest": "23.0.0",
"tslint": "^5.10.0",
"typescript": "^2.8.3",
"tslint": "^5.11.0",
"typescript": "^2.9.2",
"yargs": "^12.0.1"
},
"lint-staged": {
Expand Down
1 change: 0 additions & 1 deletion preprocessor.js

This file was deleted.

24 changes: 11 additions & 13 deletions scripts/tests.js
Expand Up @@ -13,28 +13,26 @@ function getDirectories(rootDir) {
});
}

function isJestFolder(basename) {
return basename.startsWith('__') && basename.endsWith('__');
}

// TODO: later we could add a `.test-case-keep` empty file in each folder?
// ...or move all into a `test-cases` dedicated directory
function isTestCaseFolder(basename) {
return !isJestFolder(basename);
}

function createIntegrationMock() {
const testsRoot = 'tests';
const testCaseFolders = getDirectories(testsRoot).filter(function(testDir) {
return !(testDir.startsWith('__') && testDir.endsWith('__'));
});
const testCaseFolders = getDirectories(testsRoot).filter(isTestCaseFolder);

testCaseFolders.forEach(directory => {
const testCaseNodeModules = path.join(testsRoot, directory, 'node_modules');

const rootDir = path.resolve('.');
const testCaseModuleFolder = path.join(testCaseNodeModules, 'ts-jest');

// Copy javascript files
fs.copySync(
path.resolve(rootDir, 'index.js'),
path.resolve(testCaseModuleFolder, 'index.js')
);
fs.copySync(
path.resolve(rootDir, 'preprocessor.js'),
path.resolve(testCaseModuleFolder, 'preprocessor.js')
);

// Copy package.json
fs.copySync(
path.resolve(rootDir, 'package.json'),
Expand Down
16 changes: 16 additions & 0 deletions src/index.ts
@@ -0,0 +1,16 @@
import getCacheKey from './utils/get-cache-key';
import preprocess from './preprocess';

const createTransformer = (options?: any): jest.Transformer => {
// options are always empty, must be the older jest API giving options here
return {
canInstrument: true,
getCacheKey,
process: preprocess,
createTransformer: undefined as any,
};
};

const mod = createTransformer();
mod.createTransformer = createTransformer;
export = mod;
106 changes: 0 additions & 106 deletions src/jest-types.ts

This file was deleted.

0 comments on commit 9e61969

Please sign in to comment.