-
Notifications
You must be signed in to change notification settings - Fork 0
Coverage Reporter
If you want to use the code coverage feature of testacular you need to configure three parts.
- Reporter
coverage
(required) - Preprocessor
coverage
(required) - Reporter Options (optional)
To activate the coverage reporter add this to your configuration file.
reporters = ['coverage'];
This will create a coverage report for every browser that the tests are run in. In addition, it will create a JSON file that outputs the intermediate data.
The preprocessor configures which files should be tested for coverage.
For example if all your code lives in lib/
you need to add this to your
configuration file.
preprocessors = {
'**/lib/*.js': 'coverage'
};
You should not however include the files that aren't directly related to your program, e.g. libraries, mocks.
This is a BAD example
files = [
JASMINE,
JASMINE_ADAPTER,
'lib/*.js',
'test/*.js'
];
preprocessors = {
'**/*.js': 'coverage'
};
In this example also JASMINE and JASMINE_ADAPTER get included but they shouldn't as these file are only for the test setup used and not for your program.
If you include these files there can occur side effects like the following,
- a part of the code coverage report will be output in the installation directory of testacular.
- the code coverage rate is reduced unfairly.
The reporter defaults to the following values.
coverageReporter = {
type : 'html',
dir : 'coverage/'
}
If you want to configure it yourself here are the options explained.
- Type. String
-
Possible Values.
-
html
(default) -
lcov
(lcov and html) lcovonly
text
text-summary
-
cobertura
(xml format supported by Jenkins)
-
If you set type
to text
or text-summary
, you may set the file
option, like this.
coverageReporter = {
type : 'text',
dir : 'coverage/',
file : 'coverage.txt'
}
If no filename is given, it will write the output to the console.
- Type. String
-
Description. This will be used to output coverage reports. When
you set a relative path, the directory is resolved against the
basePath
.