Yeti 0.2.27 — First-class code coverage
Yeti 0.2.27 provides first-class code coverage reporting provided by Istanbul.
Simply use Yeti with the -c
or --coverage
option. By default, Yeti will instrument your code on-the-fly and show a brief summary.
$ yeti -c
Found 1 file to test.
Agent connected: Chrome (34.0.1825.4) / Mac OS from 127.0.0.1
✓ Testing started on Chrome (34.0.1825.4) / Mac OS
✓ Agent completed: Chrome (34.0.1825.4) / Mac OS
Coverage summary:
Statements : 96.02% ( 1110/1156 )
Branches : 88.53% ( 772/872 )
Functions : 97.45% ( 229/235 )
Lines : 96.27% ( 1110/1153 )
✓ 397 tests passed! (7 seconds)
Use the --coverage-report
option to generate reports written to ./coverage
or another directory defined by --coverage-dir
. Values for --coverage-report
include:
lcov
for LCOV and HTML reports.lcovonly
for LCOV without HTML.html
for HTML only.json
for Istanbul JSON.summary
for the default summary shown above.- Any other report supported by Istanbul.
Excluding files from instrumentation
Yeti instruments all JavaScript files automatically with Istanbul. If you'd prefer to instrument
your JavaScript code with Istanbul as a part of a build step, you can pass --no-instrument
to skip all instrumenting. Yeti will still generate code coverage reports if used with
the --coverage
option.
If you'd like to exclude some JavaScript files from instrumenting, you can pass multiple
--instrument-exclude
options defining minimatch patterns to exclude.
$ yeti -c --instrument-exclude "vendor/**" --instrument-exclude "**.nocover.js"
To prevent needing to specify these verbose options every time, you can put a
coverageOptions
object in your project's .yeti.json
file containing configuration
that is only used with --coverage
.
In this example, YUI defines options that disable built-in instrumentation and passes the query string parameter filter=coverage
to cause its tests to load pre-instrumented files:
$ cd yui3/src/app
$ cat ../../.yeti.json
{
"basedir": ".",
"glob": "**/tests/unit/*.html",
"coverageOptions": {
"instrument": false,
"query": "filter=coverage"
}
}
$ yeti -c # will run with --no-instrument --query "filter=coverage"
Found 1 file to test.
Agent connected: Chrome (34.0.1825.4) / Mac OS from 127.0.0.1
✓ Testing started on Chrome (34.0.1825.4) / Mac OS
✓ Agent completed: Chrome (34.0.1825.4) / Mac OS
Coverage summary:
Statements : 96.02% ( 1110/1156 )
Branches : 88.53% ( 772/872 )
Functions : 97.45% ( 229/235 )
Lines : 96.27% ( 1110/1153 )
✓ 397 tests passed! (7 seconds)
Prefer --caps for browser launching
Yeti 0.2.25 introduced the --caps
option that lets you specify Selenium capabilities directly instead of using Yeti's --browser
option. The --browser
option allowed for shorthand to be used for launching browsers like -b firefox/xp
; however, transforming the shorthand into Selenium capabilities is difficult because many services name operating systems and browsers differently. Should we intrepret the shorthand xp
as XP
, WINDOWS
, or Windows XP
?
That's why this release deprecates --browser
in favor of --caps
. The --browser
option will continue to be supported until Yeti 0.3, but if you're using Yeti to launch browsers, we recommend that you switch to using --caps
. For the exact capabilities to use, check the documentation for your Selenium provider, such as the platforms page for Sauce Labs. For example, this will launch Firefox 26 on Sauce Labs:
yeti --caps "browserName=firefox;version=26;platform=Windows XP" test.html
Get Yeti
Install the latest version of Yeti with npm install -g yeti
. Thanks and enjoy!