-
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
Enable using 'ts-jest' package name as transform (Take 2) + fix #367 #373
Conversation
… to avoid hitting "Cannot find module '../../package' from 'node.js'" error - Change scripts/tests.js to copy the package sources, replacing the require('../../../../etc') hack (which for some reason caused kulshekhar#367 not to trip!?)
I changed the title because "Change entry to preprocessor.js" is not longer true. |
index.js
Outdated
}, | ||
install: require('./dist/install').install, | ||
}; |
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.
You'd want to export the getCacheKey
function here as well, right?
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.
Yes, good catch, thanks!
@@ -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 comment
The 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 ../../preprocessor.js
makes sure that the tests run on the current source code. Wouldn't using ts-jest
(directly or with <rootDir>
cause the tests to use the previously published version of ts-jest?
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.
Using ../../preprocessor.js makes sure that the tests run on the current source code. Wouldn't using ts-jest (directly or with cause the tests to use the previously published version of ts-jest?
No, I changed scripts/tests.js
to copy the current source code under each test project's node_packages/ts-jest/**
:
/~https://github.com/kulshekhar/ts-jest/pull/373/files#diff-0c26479cc3f82df625bd35543ed2aee0R51
"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.
Need a blank line at the end here
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.
Sure. fwiw, this was copy pasted from imports-test
.
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.
Fixed
Cool thanks 👍 |
-- Add missing getCacheKey() to the ts-jest module interface -- Fix missing newlines at end of tsconfig.json - Add integration test case to test the interface of the ts-jest module - Add missing index.d.ts, this no longer gets generated automatically because there is no longer a index.ts
} | ||
|
||
declare const tsJestModule: TsJestModule; | ||
export = tsJestModule; |
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 that dist/index.d.ts
was missing.
I just added this file to replace it. This reflects the manually written index.js
. Its gets copied to dist/
as part of the "build"
package script.
Something seems to have broken the build |
@kulshekhar Fixed it! |
@kulshekhar could you take another look? Thanks! |
I'm not sure I'm gonna have the time needed to look again closely at this in the next few days. So I'm gonna go ahead and merge and publish this now and can revisit this in case this breaks things for someone! |
@martijnthe this has been published. Thanks for the PR! |
@kulshekhar thanks! |
@kulshekhar @screendriver @GeeWee I dug into #367
The bug is in babel-core: babel/babel#6524
What changed was that
require('ts-jest')
would end up requiringbabel-core
(it's used by theprocess()
function), whereas before my patch it did not do that. To avoid hitting thebabel-core
bug, I changed the code to lazilyrequire()
the preprocessor, so thatbabel-core
does not get dragged in whenrequire('ts-jest').install()
runs.I changed the
scripts/tests.js
to copy the package sources, replacing therequire('../../../../etc')
hack. For some reason, I could not get #367 to happen in the integration test that I added with that hack in place.I think it's better now because 1) the thing under test is not modified, but instead the code as it will be distributed gets tested 2) the Jest
"transform"
configuration in thepackage.json
does no longer refer to a parent path, but the config that one would normally use in a real project.In this PR I re-reverted #368 and added the bugfix on top of it.