-
Notifications
You must be signed in to change notification settings - Fork 453
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
fix for decorator coverage #488
Changes from all commits
e4fd8d1
dcd3432
f92a728
60dac3c
d8d096f
0253ac2
522385a
039cb69
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 |
---|---|---|
|
@@ -55,14 +55,28 @@ export function process( | |
fileName: filePath, | ||
}); | ||
|
||
let tsTranspiledText = tsTranspiled.outputText; | ||
if (tsJestConfig.ignoreCoverageForAllDecorators === true) { | ||
tsTranspiledText = tsTranspiledText.replace( | ||
/__decorate/g, | ||
'/* istanbul ignore next */__decorate', | ||
); | ||
} | ||
if (tsJestConfig.ignoreCoverageForDecorators === true) { | ||
tsTranspiledText = tsTranspiledText.replace( | ||
/(__decorate\(\[\r?\n[^\n\r]*)\/\*\s*istanbul\s*ignore\s*decorator(.*)\*\//g, | ||
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. As it's 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. the comment is actually processed by istanbul and not by ts-jest so the current form is correct |
||
'/* istanbul ignore next$2*/$1', | ||
); | ||
} | ||
|
||
const postHook = getPostProcessHook( | ||
compilerOptions, | ||
jestConfig, | ||
tsJestConfig, | ||
); | ||
|
||
const outputText = postHook( | ||
tsTranspiled.outputText, | ||
tsTranspiledText, | ||
filePath, | ||
jestConfig, | ||
transformOptions, | ||
|
@@ -71,7 +85,7 @@ export function process( | |
const modified = | ||
tsJestConfig.disableSourceMapSupport === true | ||
? outputText | ||
: injectSourcemapHook(filePath, tsTranspiled.outputText, outputText); | ||
: injectSourcemapHook(filePath, tsTranspiledText, outputText); | ||
|
||
flushLogs(); | ||
|
||
|
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.
I think the name for this configuration option is a bad choice. I'd recommend something such as
enableDecoratorIgnoreComment
. Maybe this should simply betrue
always and not configurable.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.
As this is basically a fix for using typescript with istanbul I think both should default to
true
.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.
It's not set to true by default because ts-jest is not the right place for this. It is only being put in here because it seems like the fastest option to help address this issue and this shouldn't affect users who don't care about this part