Skip to main content

JavaScript

The following sections provide information on using Testspace with popular JavaScript test frameworks and tools.

To push collected files simply use the Testspace client:

$ testspace static-analysis-results test-results code-coverage-results

Test Frameworks#

Chutzpah#

Chutzpah is an open source JavaScript test runner.

Testspace accepts the JUnit XML formatted Test results. Here is an example of how to produce such:

chutzpah.console /junit report.xml

In the Testspace client command-line reference report.xml as "test-results" file.

Intern#

Intern is a complete test stack for JavaScript.

Testspace accepts JUnit XML formatted Test results. Here is an example of how to produce such:

intern-client reporters=junit

In the Testspace client command-line reference report.xml as "test-results" file.

Jasmine#

Jasmine is a Behavior Driven Development testing framework for JavaScript.

JavaScript Jasmine sample: https://github.com/testspace-samples/javascript.jasmine

Testspace accepts JUnit XML formatted Test results. To produce such the JUnitXmlReporter needs to be configured with your test runner. Assuming you are using Gulp JS build system and it configured to put the generated report files at ./reports, simply run your tests:

gulp test

If running via Grunt, using the Jasmine task:

grunt jasmine --junit.path=./reports

or if running via jasmine-node:

jasmine-node --junitreport --output=./reports

In the Testspace client command-line reference ./reports/junitresults.xml as "test-results" file.

Jest#

Jest is a complete and easy to set-up JavaScript testing solution.

Testspace accepts JUnit XML formatted Test results. Assuming jest-junit is installed and configured, here is an example of how to produce such:

JEST_JUNIT_SUITE_NAME="{filepath}" JEST_JUNIT_CLASSNAME="{classname}" JEST_JUNIT_TITLE="{title}" \
jest --reporters="jest-junit"

In the Testspace client command-line reference ./junit.xml as "test-results" file.

Karma#

Karma is a spectacular test runner for JavaScript.

Testspace accepts JUnit XML formatted Test results. To produce such the karma-junit-reporter needs to be configured to save results to ./reports output directory.

In the Testspace client command-line reference ./reports/TESTS-*.xml as "test-results" file.

Lab#

lab is a simple test utility for Node.js.

Testspace accepts JUnit XML formatted Test results. Here is an example of how to produce such:

lab --reporter=junit --output=junit.xml

In the Testspace client command-line reference ./junit.xml as "test-results" file.

Mocha#

Mocha is a feature-rich JavaScript test framework running on Node.js.

JavaScript Mocha sample: https://github.com/testspace-samples/javascript.mocha

Testspace accepts JUnit XML formatted Test results. To produce such the xunit reporter needs to be configured with your test runner. Assuming you are using Jake build system and it configured to put the generated report files at ./reports, simply run your tests:

jake test

or if running standalone

mocha --reporter xunit --reporter-options output=./reports/xunit.xml

In the Testspace client command-line reference ./reports/xunit.xml as "test-results" file.

Node-tap#

Node-tap is a TAP test framework for Node.js.

Testspace accepts JUnit XML formatted Test results. Here is an example of how to produce such:

tap --reporter=xunit > ./reports/xunit.xml

In the Testspace client command-line reference ./reports/xunit.xml as "test-results" file.

Test'em#

Test'em is a test runner that makes Javascript unit testing fun.

Testspace accepts JUnit XML formatted Test results. Here is an example of how to produce such:

testem ci --reporter xunit --report_file=./reports/xunit.xml

In the Testspace client command-line reference ./reports/xunit.xml as "test-results" file.

QUnit#

QUnit is a powerful, easy-to-use JavaScript unit testing framework.

Testspace accepts JUnit XML formatted Test results. To produce such the JUnit Reporter needs to be configured to log the XML string to report.xml file.

In the Testspace client command-line reference report.xml as "test-results" file.

Code Coverage#

Intern#

The Intern test framework has built-in support for code coverage.

Testspace accepts Cobertura XML formatted results. Here is an example of how to produce such:

intern-client reporters=cobertura

In the Testspace client command-line reference cobertura-coverage.xml as "code-coverage-results" file.

Istanbul#

Istanbul is a code coverage tool for JavaScript.

Testspace accepts Clover XML formatted results. Istanbul by default generates LCOV-style reports but could be directed to generate the desired XML Report. Here is an example of how to produce such:

istanbul report clover

or if using nyc:

nyc report --reporter=clover

In the Testspace client command-line reference ./coverage/clover.xml as "code-coverage-results" file.

JSCover#

JSCover is a tool that measures code coverage for JavaScript programs.

Testspace accepts Cobertura XML formatted results. JSCover by default generates JSON-style reports but could be directed to generate the desired XML Report. Here is an example of how to produce such:

java -cp JSCover-all.jar jscover.report.Main --format=COBERTURAXML ./

In the Testspace client command-line reference ./cobertura-coverage.xml as "code-coverage-results" file.

Static Analysis#

ESLint#

ESLint is a tool for identifying and reporting on patterns in JavaScript.

Testspace accepts Checkstyle XML formatted results. Here is an example of how to produce such:

eslint --format checkstyle --output-file analysis.xml /path/to/source

In the Testspace client command-line reference analysis.xml as "static-analysis-results" file.

JSHint#

JSHint is a tool that detects errors and potential problems in JavaScript code.

Testspace accepts Checkstyle XML formatted results. Here is an example of how to produce such:

jshint --reporter=checkstyle /path/to/source > analysis.xml

In the Testspace client command-line reference analysis.xml as "static-analysis-results" file.

TSLint#

TSLint is an extensible static analysis tool that checks TypeScript code for readability, maintainability, and functionality errors.

Testspace accepts Checkstyle XML formatted results. Here is an example of how to produce such:

tslint --format=checkstyle --out=analysis.xml /path/to/source

In the Testspace client command line reference analysis.xml as "static-analysis-results" file.