Skip to content
This repository has been archived by the owner on Oct 5, 2021. It is now read-only.

Commit

Permalink
feat: jest plugin
Browse files Browse the repository at this point in the history
close #49
  • Loading branch information
urish committed Apr 16, 2018
1 parent e4d7649 commit 6897443
Show file tree
Hide file tree
Showing 4 changed files with 2,905 additions and 0 deletions.
25 changes: 25 additions & 0 deletions packages/typewiz-jest/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "typewiz-jest",
"version": "0.1.0",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"repository": "https://github.com/urish/typewiz",
"author": "Uri Shaked <[email protected]>",
"license": "MIT",
"scripts": {
"build": "rimraf dist && tsc",
"prepublish": "npm run build"
},
"files": ["dist"],
"engines": {
"node": ">= 6.4.0"
},
"dependencies": {
"ts-jest": "^22.4.2",
"typewiz": "^0.7.0"
},
"devDependencies": {
"@types/babel-core": "^6.25.3",
"rimraf": "^2.6.2"
}
}
21 changes: 21 additions & 0 deletions packages/typewiz-jest/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { getCacheKey, process as originalProcess } from 'ts-jest';
import { JestConfig, Path, TransformOptions } from 'ts-jest/dist/jest-types';
import { instrument } from 'typewiz';

function process(
src: string,
filePath: Path,
jestConfig: JestConfig,
transformOptions: TransformOptions = { instrument: false },
) {
src =
`require('typewiz').register();` +
instrument(src, filePath, {
instrumentCallExpressions: true,
instrumentImplicitThis: true,
tsConfig: 'tsconfig.json', // TODO read it from jest config?
});
return originalProcess(src, filePath, jestConfig, transformOptions);
}

export { getCacheKey, process };
21 changes: 21 additions & 0 deletions packages/typewiz-jest/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"moduleResolution": "node",
"strictNullChecks": true,
"removeComments": false,
"sourceMap": true,
"declaration": true,
"newLine": "LF",
"noEmitOnError": true,
"noUnusedLocals": true,
"noImplicitThis": true,
"noImplicitAny": true,
"noFallthroughCasesInSwitch": true,
"rootDir": "src",
"outDir": "dist",
"lib": ["es5", "es2015.core", "es2015.promise", "es2015.collection", "es2015.iterable"]
},
"include": ["src/**/*.ts"]
}
Loading

0 comments on commit 6897443

Please sign in to comment.