-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] Add iframe coverage support (#194)
Adds helper module to modify the karma config such that coverage reporting works within iframes. Co-authored-by: Tobias Sorn <[email protected]>
- Loading branch information
1 parent
751a2f9
commit 3b5e67b
Showing
17 changed files
with
856 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* Enables coverage reporting when an iframe is used. | ||
* | ||
* Will set/overwrite the config option: | ||
* - config.coverageReporter.instrumenterOptions.istanbul.coverageGlobalScope | ||
* | ||
* @param {object} config karma configuration object | ||
*/ | ||
const configureIframeCoverage = (config) => { | ||
// set the coverageGlobalScope | ||
config.coverageReporter = config.coverageReporter || {}; | ||
config.coverageReporter.instrumenterOptions = config.coverageReporter.instrumenterOptions || {}; | ||
config.coverageReporter.instrumenterOptions.istanbul = config.coverageReporter.instrumenterOptions.istanbul || {}; | ||
config.coverageReporter.instrumenterOptions.istanbul.coverageGlobalScope = | ||
"(function() { var g=window;while(!g.__karma__&&g!==g.parent){g=g.parent;}; return g; })();"; | ||
}; | ||
|
||
module.exports = { | ||
configureIframeCoverage | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.