Registry / testing / jasmine-reporters

jasmine-reporters

JSON →
library2.5.2jsnpmunverified

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-reporters
INSTALL
IMPORT
SIG · JASMINE-REPORTERS
J
jasmine-reporters
testingjavascriptv2.5.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

JUnitXmlReporter
import { JUnitXmlReporter } from 'jasmine-reporters';
import JUnitXmlReporter from 'jasmine-reporters';
All reporters are named exports in ESM. In CommonJS, they are properties of the default export object.
reporters
const reporters = require('jasmine-reporters'); const junitReporter = new reporters.JUnitXmlReporter(/* ... */);
const { JUnitXmlReporter } = require('jasmine-reporters');
For CommonJS, the module exports an object containing all reporters as properties. Direct destructuring can work but accessing via the `reporters` object is the canonical pattern shown in documentation.
jasmineReporters (global)
var junitReporter = new jasmineReporters.JUnitXmlReporter(/* ... */);
When used in browser environments by including the script tag, the reporters are exposed globally under the `jasmineReporters` object.

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.

const Jasmine = require('jasmine'); const reporters = require('jasmine-reporters'); const path = require('path'); const jasmine = new Jasmine(); // Configure a JUnit XML Reporter const junitReporter = new reporters.JUnitXmlReporter({ savePath: path.join(__dirname, 'test-results'), // Directory to save XML files filePrefix: 'test-result-', consolidateAll: true, // Consolidate all specs into a single XML file per suite use misfortunes: true }); // Add the reporter to Jasmine jasmine.addReporter(junitReporter); // Define a simple spec file for demonstration // In a real project, these would be separate files. const specCode = ` describe('A suite', function() { it('contains spec with an expectation', function() { expect(true).toBe(true); }); it('contains another spec', function() { expect(1 + 1).toBe(2); }); }); `; // Create a temporary spec file for Jasmine to find const fs = require('fs'); const specFilePath = path.join(__dirname, 'temp-spec.js'); fs.writeFileSync(specFilePath, specCode); // Configure Jasmine to find specs jasmine.specDir = __dirname; jasmine.specFiles = ['temp-spec.js']; // Execute the tests jasmine.execute(); // Clean up temporary file after tests (simplified, should use 'afterAll' in real test suite) process.on('exit', () => { if (fs.existsSync(specFilePath)) { fs.unlinkSync(specFilePath); } console.log('Test execution complete. Check test-results directory.'); });
Debug
Known issues
breakingVersion 2.x of jasmine-reporters is built exclusively for Jasmine 2.x. Using it with Jasmine 1.x will lead to runtime errors due to API incompatibilities. Conversely, older 1.x versions of jasmine-reporters are incompatible with Jasmine 2.x.
fix
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.
affects: >=2.0.0
breakingIn jasmine-reporters 2.x, reporters are no longer registered directly on the global `jasmine` object (e.g., `new jasmine.JUnitXmlReporter()`). Instead, they are accessed via the `jasmineReporters` global object in browsers or as properties of the `require('jasmine-reporters')` object in Node.js.
fix
Update your reporter instantiation calls. In browsers, use `new jasmineReporters.ReporterName(...)`. In Node.js, use `const reporters = require('jasmine-reporters'); new reporters.ReporterName(...)`.
affects: >=2.0.0
breakingConfiguration for reporters in jasmine-reporters 2.x moved from positional arguments to a single configuration object. Older 1.x code using multiple arguments will fail or behave unexpectedly.
fix
Refactor reporter constructor calls to pass a single object with key-value pairs for configuration options, e.g., `new reporters.JUnitXmlReporter({ savePath: '...', consolidateAll: true })`.
affects: >=2.0.0
gotchaWhen using `JUnitXmlReporter` or `NUnitXmlReporter` for in-browser tests run via PhantomJS, a special `__phantom_writeFile` method must be injected into the PhantomJS environment to enable file system writes. Using a custom PhantomJS runner without this injection will prevent output files from being created.
fix
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.
affects: All versions
Errors
Common errors & fixes
TypeError: jasmine.JUnitXmlReporter is not a constructor
Attempting to instantiate a reporter using the Jasmine 1.x API (`jasmine.ReporterName`) with jasmine-reporters 2.x.
fix
For jasmine-reporters 2.x, use `new jasmineReporters.JUnitXmlReporter(...)` in browsers, or `new require('jasmine-reporters').JUnitXmlReporter(...)` in Node.js.
ReferenceError: jasmineReporters is not defined
Trying to use the `jasmineReporters` global object in a Node.js environment or in a browser without the jasmine-reporters script being loaded.
fix
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.
ENOENT: no such file or directory, open '...'
The `savePath` directory specified for XML reporters (JUnit, NUnit) does not exist, and the reporter does not automatically create it.
fix
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.
Upgrade
Version history
2.5.2latest on npm
Audit
Dependencies
jasminerequiredThis package provides reporters for the Jasmine BDD testing framework. It is a peer dependency; ensure your Jasmine version is compatible with the jasmine-reporters version.
phantomjs-prebuiltoptionalRequired for browser-side file writing functionality when running tests via PhantomJS, particularly for JUnitXmlReporter and NUnitXmlReporter.
Agent activity
8 hits · last 30 days
node
8
Resources
jasmine-reporters — npm install jasmine-reporters · libregistry