Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: karma-runner/karma-coverage
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 070bba3a8378f0895ea90239a36f6b155a546d82
Choose a base ref
...
head repository: karma-runner/karma-coverage
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 32acafa90ed621abd1df730edb44ae55a4009c2c
Choose a head ref

Commits on Mar 5, 2019

  1. Copy the full SHA
    15f8b12 View commit details

Commits on Mar 15, 2019

  1. Copy the full SHA
    e288ca4 View commit details

Commits on Mar 18, 2019

  1. Copy the full SHA
    c642c6b View commit details
  2. Copy the full SHA
    d40463d View commit details
  3. Copy the full SHA
    eefaaa2 View commit details
  4. chore: Update travis config

    BREAKING CHANGE: drop support for node < 8
    hicom150 committed Mar 18, 2019
    Copy the full SHA
    00090ea View commit details

Commits on Apr 4, 2019

  1. Merge pull request #371 from hicom150/update_travis

    Drop testing on node 4, 5, 7
    johnjbarton authored Apr 4, 2019
    Copy the full SHA
    ac445f1 View commit details
  2. Copy the full SHA
    a6b0f17 View commit details
  3. Merge pull request #372 from hicom150/update_eslint_dependencies

    Update eslint dependencies
    johnjbarton authored Apr 4, 2019
    Copy the full SHA
    14c8cba View commit details
  4. Update test dependencies (#373)

    * Update travis to match parent karma project
    
    * test: Update testing dependencies
    
    * test: Fix dependency update errors
    hicom150 authored and johnjbarton committed Apr 4, 2019
    Copy the full SHA
    b51cee7 View commit details
  5. Update grunt dependencies (#374)

    * chore: Update grunt dependencies
    hicom150 authored and johnjbarton committed Apr 4, 2019
    Copy the full SHA
    b8f82a0 View commit details

Commits on Jun 19, 2019

  1. chore(deps): Use latest istanbul lib packages (#377)

    BREAKING CHANGE:
    
    This set of changes may impact some use cases.
    
    * chore: Add Updated Istanbul Dependencies
    
    The istanbul package is deprecated in favor several split packages that
    control different aspects of how istanbul works. This commit adds the
    recommended packages that will be used in future commits as
    karma-coverage's usage of istanbul is updated to the latest api.
    
    * refactor(reporter): Follow new report API
    
    This commit refactors the in memory report implementation to use the new
    istanbul report API.
    
    Report creation is removed from newer versions of the istanbul API, so
    this commit adds a set of utility functions to wrap around the new API
    and provide similar functionality as the old API. The top level export
    uses the new utility function to register the in-memory report.
    
    * refactor(preprocessor): Switch to istanbul-lib-instrument
    
    This commit updates the preprocessor to use istanbul-lib-instrument
    instead of the deprecated istanbul package. The biggest change in this
    refactor is using a callable function instead of a constructor when
    creating instrumenters
    
    The old istanbul package exposed the Instrumenter directly, allowing the
    preprocessor to create an instance of it. istanbul-lib-instrument,
    however, exposes a callable function that creates an Instrumenter.
    This commit updates the preprocessor to follow this new pattern of using
    a callable function. In order to ensure backwards compatibility, a
    utility function is added to wrap constructors with a callable function
    for creation automatically.
    
    This change allows the following configuration for creating instrumenters:
    1. An object that contains an Instrumenter constructor
    2. An Instrumenter constructor itself
    3. A callable function that returns an Instrumenter instance.
    
    This commit also uses the istanbul-lib-source-maps package to handle
    storing source maps. A global source map store registers source maps so
    they can be used later on in the reporter.
    
    * refactor(reporter): Switch to istanbul-lib-coverage
    
    This commit updates the reporter by using the istanbul-lib-coverage
    package api for handling coverage checking/management and the
    istanbul-lib-report package api for handling reporting.
    
    The new apis remove the need for collectors and remove the need to
    handle disposing collectors.
    
    * refactor: Remove unused source cache utilities
    
    This commit removes the source-cache-store and source-cache files as
    they are no longer being used. The source-map-store and
    istanbul-lib-source-maps are used instead, so these files are no longer
    needed.
    
    * feat(util): Add Reset Functionality
    
    This commit updates the report creator utility to allow resetting the
    custom reporter map.
    
    * fix(preprocessor): Track Coverage Maps Properly
    
    This commit updates the preprocessor to properly access file coverage
    when storing it in the global coverage map (when includeAllSources is
    true). The previous method did not work because the returned
    instrumented code from the default istanbul instrumenter returns the
    coverage map in a POJO object instead of JSON notation. This breaks the
    coverage regex used to match and parse the coverage map.
    
    The istanbul instrumenter offers the ability to receive the coverage map
    for the last instrumented file through a separate function, so that is
    tested for and used if it is supported. The original method is used as a
    fallback for backwards compatibility.
    
    This commit also addresses changes from the v0 instanbul instrumenter
    options. The changes are additive only to maintain backwards compatibility
    for other instrumenters.
    
    * fix(reporter): Access Data Properly to Check Coverage
    
    This commit fixes errors with accessing data properly during the
    checkCoverage method. A previous commit updated the implementation to
    use istanbul-lib-coverage, but this involved an api change to access the
    raw coverage data (which checkCoverage uses).
    
    This commit also fixes the checking coverage for each file by using a
    map to store file coverage summaries instead of merging summaries like
    the global results. Per file coverage now works as expected.
    
    * test: Update Unit Tests to use new Istanbul API
    
    This commit updates the mocking done in unit tests to properly mock the
    new istanbul API. Additionally, new unit test suites are added for the
    utility methods report-creator and source-map-store.
    pr1sm authored and johnjbarton committed Jun 19, 2019
    Copy the full SHA
    f40d6af View commit details

Commits on Aug 20, 2019

  1. Copy the full SHA
    99c0c35 View commit details
  2. chore: release v2.0.0

    johnjbarton committed Aug 20, 2019
    Copy the full SHA
    0e2800b View commit details
  3. Copy the full SHA
    57d4bd3 View commit details
  4. chore: release v2.0.1

    johnjbarton committed Aug 20, 2019
    Copy the full SHA
    9184fc0 View commit details

Commits on Sep 3, 2019

  1. Remove unused istanbul dependency (#382)

    This avoid the deprecation warning being printed on `npm install` for
    packages with a dependency on karma-coverage.
    dpogue authored and johnjbarton committed Sep 3, 2019
    Copy the full SHA
    075ece0 View commit details

Commits on Sep 26, 2019

  1. Copy the full SHA
    b76db9e View commit details

Commits on Sep 30, 2019

  1. Make travis file simpler (#386)

    * Make travis file simpler
    
    the are two reasons
    1. Since of May 2019 by default start Ubuntu Xenial 16.04
    https://blog.travis-ci.com/2019-04-15-xenial-default-build-environment
    2. and also since Ubuntu 16.04 you can start xvfb as services
    https://docs.travis-ci.com/user/gui-and-headless-browsers/#using-xvfb-to-run-tests-that-require-a-gui
    
     - move xvfb to services
     - Remove update npm (it was need for old versions of node)
    
    * travis executes export DISPLAY=:99.0 when service xvfb start and don't need repeat again
    anthony-redFox authored and johnjbarton committed Sep 30, 2019
    Copy the full SHA
    9c8a222 View commit details

Commits on Oct 1, 2019

  1. chore(all): Migrate to ES6 (#385)

    * Convert InMemoryReport to the ES6 class
    
    * Use default params for reporters and coverageReporter
    
    * Remove lodash usages and dependencies
    
    * Replace all vars on const vs let in preprocessor
    anthony-redFox authored and johnjbarton committed Oct 1, 2019
    Copy the full SHA
    d3f53e3 View commit details

Commits on Dec 9, 2019

  1. Added debug msg whether coverage is in reporters (#396)

    * Added debug msg whether coverage is in reporters
    
    * Change log level to info if coverage is not included in reporters
    abbr authored and johnjbarton committed Dec 9, 2019
    Copy the full SHA
    b23664e View commit details
  2. Update Source Map Handling (#394)

    * refactor(preprocessor): Update Source Map Handling
    
    This commit updates the handling of source map inclusion in the
    preprocessor. Instead of attempting to combine both the incoming
    source map and instrumented source map, a single one is chosen and
    included as an inline comment of the instrumented code.
    
    This commit also adds a null/undefined check before registering an
    incoming source map in the sourceMapStore.
    
    * chore(deps): Remove unused source-map package
    
    The previous commit removes the need for the source-map package.
    
    * test(preprocessor): Update test mocks
    
    This commit updates the instrumenter mock. Since the new logic calls
    instrumenter.lastSourceMap() in more cases, this has to be mocked
    properly.
    
    * fix(preprocessor): merging source maps
    
    This commit fixes an issue where karma would be unable to report
    correctly mapped stacktraces back to original sources. Instead of
    manually merging source maps, the default instrumenter, istanbul,
    supports passing in an input source map and having that merged
    automatically with the internal source map of instrumented code.
    
    The merged source map is now available for access using
    instrumenter.lastSourceMap(), so that is what file.sourceMap gets
    updated to (if the merge completed successfully).
    
    Istanbul reporting still requires the original source map only, so the
    check to register the source map with the source store is made before
    this merged source map is used. This allows istanbul to use the original
    incoming source map, while still allowing karma to use the merged source
    map.
    pr1sm authored and johnjbarton committed Dec 9, 2019
    Copy the full SHA
    55aeead View commit details
  3. chore(deps-dev): bump eslint from 2.13.1 to 4.18.2 (#397)

    Bumps [eslint](https://github.com/eslint/eslint) from 2.13.1 to 4.18.2.
    - [Release notes](https://github.com/eslint/eslint/releases)
    - [Changelog](https://github.com/eslint/eslint/blob/master/CHANGELOG.md)
    - [Commits](eslint/eslint@v2.13.1...v4.18.2)
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and johnjbarton committed Dec 9, 2019
    Copy the full SHA
    d18cde4 View commit details
  4. chore(deps): bump lodash.template from 4.4.0 to 4.5.0 (#392)

    Bumps [lodash.template](https://github.com/lodash/lodash) from 4.4.0 to 4.5.0.
    - [Release notes](https://github.com/lodash/lodash/releases)
    - [Commits](lodash/lodash@4.4.0...4.5.0)
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and johnjbarton committed Dec 9, 2019
    Copy the full SHA
    0ee780c View commit details

Commits on Mar 18, 2020

  1. chore(deps): bump handlebars from 4.1.2 to 4.5.3 (#399)

    Bumps [handlebars](https://github.com/wycats/handlebars.js) from 4.1.2 to 4.5.3.
    - [Release notes](https://github.com/wycats/handlebars.js/releases)
    - [Changelog](https://github.com/wycats/handlebars.js/blob/master/release-notes.md)
    - [Commits](handlebars-lang/handlebars.js@v4.1.2...v4.5.3)
    
    Signed-off-by: dependabot[bot] <support@github.com>
    
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Mar 18, 2020
    Copy the full SHA
    352254a View commit details

Commits on Mar 19, 2020

  1. Copy the full SHA
    5cf931a View commit details
  2. Copy the full SHA
    4cfa697 View commit details

Commits on Mar 23, 2020

  1. Copy the full SHA
    49f174d View commit details
  2. Copy the full SHA
    83bafc3 View commit details
  3. refactor: remove isAbsolute and replace with path.isAbsolute (#405)

    path.isAbsolute added in node v0.11.2
    anthony-redFox authored Mar 23, 2020
    Copy the full SHA
    fc6e289 View commit details

Commits on Mar 24, 2020

  1. fix(reporter): update calls to match new API in istanbul-lib-report fix

    #398 (#403)
    
    BREAKING CHANGES: major dependencies are updated
    anthony-redFox authored Mar 24, 2020
    Copy the full SHA
    4962a70 View commit details

Commits on Mar 25, 2020

  1. ci: drop node 8, adopt node 12 (#409)

    BREAKING CHANGES: drop node 8
    anthony-redFox authored Mar 25, 2020
    Copy the full SHA
    1adb27a View commit details

Commits on Mar 30, 2020

  1. ci(test): use eslint as ci command and add all js files to check by e…

    …slint (#410)
    
    no-unused-expressions ignore for tests uses chai expect
    anthony-redFox authored Mar 30, 2020
    Copy the full SHA
    27822c9 View commit details

Commits on Apr 10, 2020

  1. Copy the full SHA
    9c37de6 View commit details

Commits on Apr 13, 2020

  1. Copy the full SHA
    bb8f9ee View commit details
  2. chore(release): 2.0.2 [skip ci]

    ## [2.0.2](v2.0.1...v2.0.2) (2020-04-13)
    
    ### Bug Fixes
    
    * **reporter:** update calls to  match new API in istanbul-lib-report fix [#398](#398) ([#403](#403)) ([4962a70](4962a70))
    * remove information about old istanbul lib ([#404](#404)) ([5cf931a](5cf931a))
    semantic-release-bot committed Apr 13, 2020
    Copy the full SHA
    32acafa View commit details
18 changes: 17 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
{
"extends": "standard"
"extends": "standard",
"env": {
"node": true,
"mocha": true
},
"globals": {
"expect": true,
"sinon": true
},
"overrides": [
{
"files": ["test/**/*.js"],
"rules": {
"no-unused-expressions": "off"
}
}
]
}
24 changes: 13 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
language: node_js
node_js:
- 4
- 5
- 7
- 8
- 10
- 12

# Make sure we have new NPM.
before_install:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- npm install -g npm
- npm config set loglevel warn
services:
- xvfb

before_script:
- npm install -g grunt-cli

after_success:
# run automated release process with semantic-release
- if [[ "$TRAVIS_BRANCH" == "master" && "$TRAVIS_EVENT_TYPE" == "push" && "$TRAVIS_NODE_VERSION" == "12" ]]; then
semantic-release;
fi;

script:
- grunt
- commitlint-travis
- npm run lint
- grunt
135 changes: 135 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,138 @@
## [2.0.2](https://github.com/karma-runner/karma-coverage/compare/v2.0.1...v2.0.2) (2020-04-13)


### Bug Fixes

* **reporter:** update calls to match new API in istanbul-lib-report fix [#398](https://github.com/karma-runner/karma-coverage/issues/398) ([#403](https://github.com/karma-runner/karma-coverage/issues/403)) ([4962a70](https://github.com/karma-runner/karma-coverage/commit/4962a70026efbbd77e9fa7b6bfd6be29047c1082))
* remove information about old istanbul lib ([#404](https://github.com/karma-runner/karma-coverage/issues/404)) ([5cf931a](https://github.com/karma-runner/karma-coverage/commit/5cf931afe331cfcebf7cf934ec52de933344091d))

<a name="2.0.1"></a>
## [2.0.1](https://github.com/karma-runner/karma-coverage/compare/v2.0.0...v2.0.1) (2019-08-20)



<a name="2.0.0"></a>
# [2.0.0](https://github.com/karma-runner/karma-coverage/compare/v1.1.1...v2.0.0) (2019-08-20)


### Bug Fixes

* **build:** Update to lodash 4 ([d6d21d2](https://github.com/karma-runner/karma-coverage/commit/d6d21d2)), closes [#242](https://github.com/karma-runner/karma-coverage/issues/242)
* **reporter:** replace colons in the output path ([3b2bffa](https://github.com/karma-runner/karma-coverage/commit/3b2bffa))
* bump lodash for CVE-2018-16487 ([15f8b12](https://github.com/karma-runner/karma-coverage/commit/15f8b12))


### Chores

* Update travis config ([00090ea](https://github.com/karma-runner/karma-coverage/commit/00090ea))
* **deps:** Use latest istanbul lib packages ([#377](https://github.com/karma-runner/karma-coverage/issues/377)) ([f40d6af](https://github.com/karma-runner/karma-coverage/commit/f40d6af))


### BREAKING CHANGES

* **deps:** This set of changes may impact some use cases.

* chore: Add Updated Istanbul Dependencies

The istanbul package is deprecated in favor several split packages that
control different aspects of how istanbul works. This commit adds the
recommended packages that will be used in future commits as
karma-coverage's usage of istanbul is updated to the latest api.

* refactor(reporter): Follow new report API

This commit refactors the in memory report implementation to use the new
istanbul report API.

Report creation is removed from newer versions of the istanbul API, so
this commit adds a set of utility functions to wrap around the new API
and provide similar functionality as the old API. The top level export
uses the new utility function to register the in-memory report.

* refactor(preprocessor): Switch to istanbul-lib-instrument

This commit updates the preprocessor to use istanbul-lib-instrument
instead of the deprecated istanbul package. The biggest change in this
refactor is using a callable function instead of a constructor when
creating instrumenters

The old istanbul package exposed the Instrumenter directly, allowing the
preprocessor to create an instance of it. istanbul-lib-instrument,
however, exposes a callable function that creates an Instrumenter.
This commit updates the preprocessor to follow this new pattern of using
a callable function. In order to ensure backwards compatibility, a
utility function is added to wrap constructors with a callable function
for creation automatically.

This change allows the following configuration for creating instrumenters:
1. An object that contains an Instrumenter constructor
2. An Instrumenter constructor itself
3. A callable function that returns an Instrumenter instance.

This commit also uses the istanbul-lib-source-maps package to handle
storing source maps. A global source map store registers source maps so
they can be used later on in the reporter.

* refactor(reporter): Switch to istanbul-lib-coverage

This commit updates the reporter by using the istanbul-lib-coverage
package api for handling coverage checking/management and the
istanbul-lib-report package api for handling reporting.

The new apis remove the need for collectors and remove the need to
handle disposing collectors.

* refactor: Remove unused source cache utilities

This commit removes the source-cache-store and source-cache files as
they are no longer being used. The source-map-store and
istanbul-lib-source-maps are used instead, so these files are no longer
needed.

* feat(util): Add Reset Functionality

This commit updates the report creator utility to allow resetting the
custom reporter map.

* fix(preprocessor): Track Coverage Maps Properly

This commit updates the preprocessor to properly access file coverage
when storing it in the global coverage map (when includeAllSources is
true). The previous method did not work because the returned
instrumented code from the default istanbul instrumenter returns the
coverage map in a POJO object instead of JSON notation. This breaks the
coverage regex used to match and parse the coverage map.

The istanbul instrumenter offers the ability to receive the coverage map
for the last instrumented file through a separate function, so that is
tested for and used if it is supported. The original method is used as a
fallback for backwards compatibility.

This commit also addresses changes from the v0 instanbul instrumenter
options. The changes are additive only to maintain backwards compatibility
for other instrumenters.

* fix(reporter): Access Data Properly to Check Coverage

This commit fixes errors with accessing data properly during the
checkCoverage method. A previous commit updated the implementation to
use istanbul-lib-coverage, but this involved an api change to access the
raw coverage data (which checkCoverage uses).

This commit also fixes the checking coverage for each file by using a
map to store file coverage summaries instead of merging summaries like
the global results. Per file coverage now works as expected.

* test: Update Unit Tests to use new Istanbul API

This commit updates the mocking done in unit tests to properly mock the
new istanbul API. Additionally, new unit test suites are added for the
utility methods report-creator and source-map-store.
* drop support for node < 8
* **reporter:** the output folder names change, they no longer contain `:`



<a name="1.1.2"></a>
## [1.1.2](https://github.com/karma-runner/karma-coverage/compare/v1.1.1...v1.1.2) (2018-05-03)

24 changes: 0 additions & 24 deletions LICENSE-istanbul

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -119,4 +119,4 @@ For more information on Karma see the [homepage].


[homepage]: http://karma-runner.github.com
[Istanbul]: https://github.com/gotwarlost/istanbul
[Istanbul]: https://istanbul.js.org
14 changes: 3 additions & 11 deletions gruntfile.js
Original file line number Diff line number Diff line change
@@ -8,8 +8,8 @@ module.exports = function (grunt) {
},
unit: {
src: [
'test/mocha-globals.coffee',
'test/*.spec.coffee'
'test/mocha-globals.js',
'test/*.spec.js'
]
}
},
@@ -58,20 +58,12 @@ module.exports = function (grunt) {
coffeeRequireJS: {
configFile: 'examples/coffee-requirejs/karma.conf.coffee'
}
},
eslint: {
target: [
'lib/*.js',
'gruntfile.js',
'karma.conf.js'
]
}
})

require('load-grunt-tasks')(grunt)

grunt.registerTask('test', ['simplemocha', 'karma'])
grunt.registerTask('default', ['eslint', 'test'])
grunt.registerTask('default', ['simplemocha', 'karma'])

grunt.registerTask('release', 'Bump the version and publish to NPM.', function (type) {
grunt.task.run([
33 changes: 21 additions & 12 deletions lib/in-memory-report.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
var Report = require('istanbul').Report
var util = require('util')
const { ReportBase } = require('istanbul-lib-report')

function InMemoryReport (opt) {
this.opt = opt
}
class InMemoryReport extends ReportBase {
constructor (opt) {
super(opt)
this.opt = opt
}

onStart () {
this.data = {}
}

util.inherits(InMemoryReport, Report)
onDetail (node) {
const fc = node.getFileCoverage()
const key = fc.path
this.data[key] = fc.toJSON()
}

InMemoryReport.prototype.writeReport = function (collector, sync) {
if (!this.opt.emitter || !this.opt.emitter.emit) {
console.error('Could not raise "coverage_complete" event, missing emitter because it was not supplied during initialization of the reporter')
} else {
this.opt.emitter.emit('coverage_complete', this.opt.browser, collector.getFinalCoverage())
onEnd () {
if (!this.opt || !this.opt.emitter || !this.opt.emitter.emit) {
console.error('Could not raise "coverage_complete" event, missing emitter because it was not supplied during initialization of the reporter')
return
}
this.opt.emitter.emit('coverage_complete', this.opt.browser, this.data)
}
}

InMemoryReport.TYPE = 'in-memory'

module.exports = InMemoryReport
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
// Exposes the preprocessor and reporter plugins.

// Registering one additional (karma specific) reporter: in-memory
require('istanbul').Report.register(require('./in-memory-report'))
require('./report-creator').register(require('./in-memory-report'))

module.exports = {
'preprocessor:coverage': ['factory', require('./preprocessor')],
Loading