gem install jcov
Getting Started¶ ↑
There are both JSpec and Jasmine example projects in the examples directory – these are a good place to start.
Command Line¶ ↑
- jcov run
Runs the tests. Also the default command (just type ‘jcov’)
- jcov check
Check the configuration.
- jcov help
Show help docs.
-c, --config FILE Specify a configuration file to use -h, --help Display help documentation -v, --version Display version information -t, --trace Display backtrace when an error occurs
-t, --test REGEX Limit the tests to only the ones that match the regular expression --verbose Verbose test execution --[no-]color Enable/Disable color output -- default enabled when executed from the command-line --[no-]coverage Enable/Disable coverage output -- default enabled --report Report test coverage
Running with the –report switch will output an HTML coverage report that shows line-by-line coverage.
If your testing framework supports color output your runner file must pass the color boolean value from the JCov object (JCov.options.color) to the framework (see the Jasmine and JCov examples).
The –verbose switch is another option your framework must support (see the JCov example).
Run will also return with a non-zero code when the tests don’t pass so it can be easily integrated into continuous integration suites.
Configure JCov by creating a jcov.yaml file. JCov also has some “intelligent” defaults and you can see the how the jcov.yaml file works with those defaults using the check command to output the combined configuration:
JCov will look for the jcov.yaml file in a
config directory and the current directory.
Example jcov check output:
Configuration Keys¶ ↑
Where the HTML coverage reports will be written. (Default jcov)
Runner Files¶ ↑
See the examples directory for examples.
Runner API¶ ↑
JCov provides some methods and a data object to the runner file.
The JCov object
JCov.tests: An Array of tests to execute (the list of everything from your test directory filtered by the –test switch)
JCov.config: The configuration loaded from jcov.yaml (see above)
JCov.options: Passed in command line options (see above)
print(): Print to the console.
println(): Print to the console with a carriage return.
load(): load and execute the given file.
readFile(): load file and return it as a string.
putc(): Print a single character to the console.
Headless Browser Testing¶ ↑
Copyright © YP Intellectual Property, LLC 2012. JCov is licensed under the MIT License.