-
Notifications
You must be signed in to change notification settings - Fork 460
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
Enable using 'ts-jest' package name as transform (Take 2) + fix #367 #373
Changes from all commits
895b919
b7eb181
4346702
f17bf81
91a1f0e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import * as _install from './install'; | ||
import * as preprocessor from './preprocessor'; | ||
|
||
interface TsJestModule { | ||
install: typeof _install.install; | ||
process: typeof preprocessor.process; | ||
getCacheKey: typeof preprocessor.getCacheKey; | ||
} | ||
|
||
declare const tsJestModule: TsJestModule; | ||
export = tsJestModule; | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,16 @@ | ||
module.exports = require('./dist/index'); | ||
// Avoid require()'ing the preprocessor when index.js gets loaded as part | ||
// of the transpiled test file output, to avoid tripping this bug in | ||
// babel-core: /~https://github.com/babel/babel/pull/6524 which is to be | ||
// fixed in babel-core 7.0. | ||
// Related ts-jest issue: /~https://github.com/kulshekhar/ts-jest/issues/367 | ||
function lazyRequire(fnName) { | ||
return function() { | ||
return require('./dist/preprocessor')[fnName].apply(null, arguments); | ||
}; | ||
} | ||
|
||
module.exports = { | ||
process: lazyRequire('process'), | ||
getCacheKey: lazyRequire('getCacheKey'), | ||
install: require('./dist/install').install, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import runJest from '../__helpers__/runJest'; | ||
|
||
// Regression test for | ||
// /~https://github.com/kulshekhar/ts-jest/issues/367 | ||
describe('no json in moduleFileExtensions', () => { | ||
it('should run successfully', () => { | ||
const result = runJest('../no-json-module-file-ext', ['--no-cache']); | ||
expect(result.status).toBe(0); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import runJest from '../__helpers__/runJest'; | ||
|
||
describe('ts-jest module interface', () => { | ||
it('should run successfully', () => { | ||
const result = runJest('../ts-jest-module-interface', ['--no-cache']); | ||
expect(result.status).toBe(0); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"jest": { | ||
"transform": { | ||
".(ts|tsx)": "../../preprocessor.js" | ||
".(ts|tsx)": "ts-jest" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This applies to all test files with similar changes This doesn't look right. Using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
No, I changed /~https://github.com/kulshekhar/ts-jest/pull/373/files#diff-0c26479cc3f82df625bd35543ed2aee0R51 |
||
}, | ||
"moduleDirectories": [ | ||
"node_modules", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,4 @@ | |
"allowJs": true, | ||
"baseUrl": "src" | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
test('no json in moduleFileExtensions', () => {}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"jest": { | ||
"transform": { | ||
"^.+\\.tsx?$": "ts-jest" | ||
}, | ||
"moduleDirectories": [ | ||
"node_modules", | ||
"src" | ||
], | ||
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$", | ||
"moduleFileExtensions": [ | ||
"ts", | ||
"tsx", | ||
"js", | ||
"jsx", | ||
"the.important.thing.is.that.json.is.missing.here" | ||
] | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ES5", | ||
"module": "commonjs", | ||
"moduleResolution": "node", | ||
"noEmitOnError": false, | ||
"jsx": "react", | ||
"allowJs": true, | ||
"baseUrl": "src" | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kulshekhar:
While writing the new
ts-jest-module-interface
test case, I found out thatdist/index.d.ts
was missing.I just added this file to replace it. This reflects the manually written
index.js
. Its gets copied todist/
as part of the"build"
package script.