jasmine-reporters is a collection of JavaScript reporter classes designed for the Jasmine BDD testing framework. As of version 2.5.2, it primarily supports Jasmine 2.x, with a dedicated branch and older npm versions available for Jasmine 1.x compatibility. The library offers a variety of output formats, including standard options like JUnit XML, NUnit XML, and TAP (Test Anything Protocol), alongside specialized reporters for build systems such as TeamCity and AppVeyor, and a colorized Terminal Reporter. It differentiates itself by providing robust support for both Node.js environments and in-browser testing via PhantomJS, including mechanisms for local filesystem writes in headless browser contexts. While no explicit release cadence is documented, major versions of jasmine-reporters historically align with significant Jasmine framework updates, requiring users to match the reporter library version to their Jasmine version.
npm install jasmine-reportersVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to set up and use the JUnitXmlReporter with Jasmine in a Node.js environment, showing how to instantiate the reporter and add it to Jasmine, then execute a basic test suite.
Ensure your jasmine-reporters version matches your Jasmine framework's major version. For Jasmine 1.x, use `npm install jasmine-reporters@^1.0.0`. For Jasmine 2.x, use `npm install jasmine-reporters@^2.0.0` or higher.
Update your reporter instantiation calls. In browsers, use `new jasmineReporters.ReporterName(...)`. In Node.js, use `const reporters = require('jasmine-reporters'); new reporters.ReporterName(...)`.Refactor reporter constructor calls to pass a single object with key-value pairs for configuration options, e.g., `new reporters.JUnitXmlReporter({ savePath: '...', consolidateAll: true })`.It is strongly recommended to use the `phantomjs.runner.sh` script provided by `jasmine-reporters` as it handles the `__phantom_writeFile` injection. If using a custom runner, ensure you manually inject this method and handle test completion detection.
For jasmine-reporters 2.x, use `new jasmineReporters.JUnitXmlReporter(...)` in browsers, or `new require('jasmine-reporters').JUnitXmlReporter(...)` in Node.js.In Node.js, use `const reporters = require('jasmine-reporters');`. In a browser, ensure the jasmine-reporters script is loaded via a `<script>` tag before your test setup code.Ensure the directory specified in the `savePath` option exists before running tests. You may need to create it programmatically using `fs.mkdirSync(path, { recursive: true })` in Node.js.