Coder Social home page Coder Social logo

jasmine-coberturareporter's Introduction

jasmine-coberturareporter

Cobertura coverage compatible output for Jasmine tests.

Usage

  • Download jscoverage (protip: Chef Cookbook)
  • Download PhantomJS (protip: Chef Cookbook)
  • Run jsCoverage to instrument the javascript files you want to run coverage for
  • Include the instrumented files in your test runner page
  • Add the jasmine-coberturareporter as a reporter in your test runner page
  • Tell jasmine-coberturareporter where you want the XML report and where your source files live
  • Run through something like PhantomJS through the included phantom-testrunner.js file

Adding the reporter

Add this line to your test runner page:

jasmine.getEnv().addReporter(new jasmine.CoberturaReporter(<output_path>, <uninstrumented_javascript_path>));

Example Test Runner

<!doctype html>
<html>
<head>
	<title>Test Runner</title>

	<script type="text/javascript" src="js/lib/jasmine-1.2.0/jasmine.js"></script>
	<script type="text/javascript" src="js/lib/jasmine-1.2.0/jasmine-html.js"></script>
	<script type="text/javascript" src="js/lib/jasmine.cobertura-reporter.js"></script>

	<script type="text/javascript" src="js-instrumented/file-to-test.js"></script>
</head>

<body>
	<script type="text/javascript">
		jasmine.getEnv().addReporter(new jasmine.TrivialReporter());
		jasmine.getEnv().addReporter(new jasmine.CoberturaReporter('./reports/', 'public/js/'));
		jasmine.getEnv().execute();
	</script>
</body>
</html>

Example command

Stick this up your Jenkins (or equivalent CI environment):

# Run jscoverage to instrument javascript source files
jscoverage public/js/ public/js-instrumented/

# Run phantomJS through the testrunner
phantomjs phantom-testrunner.js $WORKSPACE/public/test-runner.html

Other recommended outputs

This combines well with jasmine-junitreporter and jasmine-consolereporter to give you both a meaningful output on the console and subsequent jUnit XML to breakdown the output spec-by-spec.

Aknowledgements

The structure of the reporter was built-on the jscoverage-reporter project by Daniel Rinehart.

The included phantom-testrunner.js is taken from the jasmine-reporters project by Larry Myers.

jasmine-coberturareporter's People

Contributors

chrisblackburn avatar

Stargazers

funkfan82 avatar Fabio Ribeiro avatar  avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.