3.0.0 • Published 1 month ago

ember-cli-code-coverage v3.0.0

Weekly downloads
50,257
License
MIT
Repository
github
Last release
1 month ago

ember-cli-code-coverage npm version Build Status

Code coverage using Istanbul for Ember apps.

Requirements

  • If using Mocha, Testem >= 1.6.0 for which you need ember-cli > 2.4.3
  • If using Mirage you need ember-cli-mirage >= 0.1.13
  • If using Pretender (even as a dependency of Mirage) you need pretender >= 0.11.0
  • If using Mirage or Pretender, you need to set up a passthrough for coverage to be written.
  • ember-cli-babel >= 6.0.0

Installation

  • ember install ember-cli-code-coverage

Usage

Coverage will only be generated when an environment variable is true (by default COVERAGE) and running your test command like normal.

For example:

COVERAGE=true ember test

If you want your coverage to work on both Unix and Windows, you can do this:

npm install cross-env --save-dev

and then:

cross-env COVERAGE=true ember test

When running with parallel set to true, the final reports can be merged by using ember coverage-merge. The final merged output will be stored in the coverageFolder.

Configuration

Configuration is optional. It should be put in a file at config/coverage.js (configPath configuration in package.json is honored). In addition to this you can configure Istanbul by adding a .istanbul.yml file to the root directory of your app (See https://github.com/gotwarlost/istanbul#configuring)

Options

  • coverageEnvVar: Defaults to COVERAGE. This is the environment variable that when set will cause coverage metrics to be generated.

  • reporters: Defaults to ['lcov', 'html']. The json-summary reporter will be added to anything set here, it is required. This can be any reporters supported by Istanbul.

  • excludes: Defaults to ['*/mirage/**/*']. An array of globs to exclude from instrumentation. Useful to exclude files from coverage statistics.

  • coverageFolder: Defaults to coverage. A folder relative to the root of your project to store coverage results.

  • parallel: Defaults to false. Should be set to true if parallel testing is being used, for example when using ember-exam with the --parallel flag. This will generate the coverage reports in directories suffixed with _<random_string> to avoid overwriting other threads reports. These reports can be joined by using the ember coverage-merge command (potentially as part of the posttest hook in your package.json).

Example

  module.exports = {
    coverageEnvVar: 'COV'
  }

Create a passthrough when intercepting all ajax requests in tests

To work, this addon has to post coverage results back to a middleware at /write-coverage.

If you are using ember-cli-mirage you should add the following:

// in mirage/config.js

  this.passthrough('/write-coverage');
  this.namespace = 'api';  // It's important that the passthrough for coverage is before the namespace, otherwise it will be prefixed.

If you are using ember-cli-pretender you should add the following:

// where ever you set up the Pretender Server

  var server = new Pretender(function () {
    this.post('/write-coverage', this.passthrough);
  });

Inspiration

This addon was inspired by ember-cli-blanket. The primary differences are that this addon uses Istanbul rather than Blanket for coverage and it instruments your application code as part of the build, when enabled.

3.0.0

1 month ago

2.1.2

1 month ago

2.1.1

2 months ago

2.1.0

2 months ago

2.0.3

5 months ago

2.0.2

6 months ago

2.0.0

1 year ago

2.0.0-beta.4

2 years ago

2.0.0-beta.3

2 years ago

2.0.0-beta.2

3 years ago

2.0.0-beta.1

3 years ago

1.0.3

3 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

1.0.0-beta.9

4 years ago

1.0.0-beta.8

5 years ago

1.0.0-beta.7

5 years ago

1.0.0-beta.6

6 years ago

1.0.0-beta.5

6 years ago

1.0.0-beta.4

6 years ago

1.0.0-beta.3

6 years ago

1.0.0-beta.2

6 years ago

1.0.0-beta.1

6 years ago

1.0.0-beta.0

6 years ago

0.4.2

7 years ago

0.4.1

7 years ago

0.4.0

7 years ago

0.3.12

7 years ago

0.3.11

7 years ago

0.3.10

7 years ago

0.3.9

7 years ago

0.3.8

7 years ago

0.3.7

8 years ago

0.3.6

8 years ago

0.3.5

8 years ago

0.3.4

8 years ago

0.3.3

8 years ago

0.3.2

8 years ago

0.3.1

8 years ago

0.3.0

8 years ago

0.2.2

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago

0.0.1

8 years ago