Registry / testing / jasmine-spec-reporter

jasmine-spec-reporter

JSON →
library7.0.0jsnpmunverified

jasmine-spec-reporter is a console reporter for the Jasmine behavior-driven development framework, providing real-time output of test results directly in the terminal. It is currently stable at version 7.0.0. The latest major release (v7.0.0) was published in April 2021, indicating a slower release cadence in recent years. The library is designed to offer a highly customizable and readable test reporting experience, especially beneficial in Node.js and Protractor test environments, and ships with comprehensive TypeScript type definitions. Key differentiators include extensive configuration options for output formatting, such as support for different stacktrace displays (none, raw, pretty) and customizable color themes for various test states. It offers a more detailed and configurable spec-by-spec breakdown compared to Jasmine's default reporter.

npm install jasmine-spec-reporter
INSTALL
IMPORT
SIG · JASMINE-SPEC-REPOR
J
jasmine-spec-reporter
testingjavascriptv7.0.0
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.

SpecReporter
import { SpecReporter } from 'jasmine-spec-reporter'
const SpecReporter = require('jasmine-spec-reporter')
While CommonJS `require` might work in some older Node.js/Jasmine setups, ESM `import` is the standard and recommended approach for modern environments. The package ships with TypeScript types.
StacktraceOption
import { StacktraceOption } from 'jasmine-spec-reporter'
This enum is used for configuring the `displayStacktrace` option within the `SpecReporter` configuration object. It was introduced in v5.0.0, replacing a boolean configuration.
DisplayProcessor
import { DisplayProcessor } from 'jasmine-spec-reporter'
This is the base class for creating custom output processors to tailor how test results are displayed. Its method signatures were updated in v4.0.0 from `String` to `string`, and the coloring mechanism changed in v6.0.0.
CustomReporterResult
import { CustomReporterResult } from 'jasmine-spec-reporter'
This TypeScript interface is used by custom display processors to access detailed test results. Its signature was updated in v7.0.0 to fix potential type collisions with new properties introduced in Jasmine, specifically moving `duration` to a nested `_jsr` property.

Demonstrates how to install and configure `jasmine-spec-reporter` with a minimal Jasmine test suite, showcasing basic options like stacktrace display and color settings.

import { SpecReporter, StacktraceOption } from 'jasmine-spec-reporter'; import * as Jasmine from 'jasmine'; // Ensure 'jasmine' package is installed const runner = new Jasmine(); // Clear any default reporters to avoid duplicate output runner.env.clearReporters(); // Add the SpecReporter with custom configuration runner.env.addReporter(new SpecReporter({ spec: { displayStacktrace: StacktraceOption.PRETTY, // Options: 'pretty', 'raw', 'none' displayDuration: true, }, suite: { displayNumber: true, }, summary: { displayPending: false, displayFailed: true, displayDuration: true, }, colors: { success: 'green', failure: 'red', pending: 'yellow', }, // For advanced customization, you can add custom processors: // customProcessors: [new MyCustomDisplayProcessor()], })); // Define a simple test suite for demonstration purposes runner.describe('A basic test suite', () => { runner.it('should pass an assertion', () => { runner.expect(true).toBe(true); }); runner.it('should fail an assertion', () => { runner.expect(1).toBe(2); }); runner.pending('should be a pending test that is not run'); }); // Execute the tests (in a real scenario, this might be handled by a test runner) runner.execute();
Debug
Known issues
breakingThe `CustomReporterResult` interface signature was updated to fix collisions with new Jasmine properties. Specifically, `duration` property moved from the top level to `_jsr?: { formattedDuration?: string }`.
fix
If extending `CustomReporterResult` in TypeScript, update your interface to reflect the `_jsr` nested property for duration information.
affects: >=7.0.0
breakingString prototype extensions for colors (e.g., `"OK ".successful`) are no longer supported. Colors must now be applied via the `theme` component available in custom display processors.
fix
Update custom display processors to use `this.theme.successful('OK ')` instead of `String.prototype` extensions for applying colors.
affects: >=6.0.0
breakingThe `displayStacktrace` option in the reporter configuration changed from a boolean to an enum (`StacktraceOption.NONE`, `StacktraceOption.RAW`, `StacktraceOption.PRETTY`).
fix
Update your configuration to use `StacktraceOption.PRETTY` (or `RAW`, `NONE`) instead of a boolean value for `displayStacktrace`.
affects: >=5.0.0
breakingThe `DisplayProcessor` methods signature in TypeScript changed from using `String` wrapper objects to `string` primitive types for log parameters and return values.
fix
If you have custom `DisplayProcessor` implementations in TypeScript, update method signatures to use `string` instead of `String` (e.g., `log: string` instead of `log: String`).
affects: >=4.0.0
gotchaThe `jasmine-spec-reporter` package needs to be explicitly added to Jasmine's environment via `jasmine.env.addReporter()`. It is not automatically loaded or added to the global `jasmine` object in newer versions.
fix
Ensure you are explicitly calling `jasmine.env.addReporter(new SpecReporter(...))` in your test setup file (e.g., `jasmine.json` helper or `protractor.conf.js`).
affects: >=2.x
Errors
Common errors & fixes
TS2345: Argument of type 'SpecReporter' is not assignable to parameter of type 'CustomReporter'.
Type mismatch between `jasmine-spec-reporter`'s `SpecReporter` and `@types/jasmine`'s `CustomReporter` interface, often due to differing versions.
fix
Ensure compatible versions of `jasmine-spec-reporter` and `@types/jasmine`. A temporary workaround might be to use a type assertion: `jasmine.env.addReporter(new SpecReporter(...) as any);` or `as jasmine.CustomReporter;`.
Property 'successful' does not exist on type 'String'. Did you mean 'toLowerCase'?
Attempting to use deprecated String prototype extensions for applying colors within custom display processors after upgrading to v6.0.0 or higher.
fix
Modify your custom `DisplayProcessor` to use the injected `this.theme` object for colorization, e.g., `return this.theme.successful('OK ') + log;`.
TypeError: Cannot read properties of undefined (reading 'PRETTY')
Using `StacktraceOption.PRETTY` (or `RAW`, `NONE`) without importing `StacktraceOption` from `jasmine-spec-reporter`.
fix
Add `import { StacktraceOption } from 'jasmine-spec-reporter';` to your file where `SpecReporter` is configured.
Error: 'displayStacktrace' must be one of 'none', 'raw', 'pretty'
Configuring `displayStacktrace` with a boolean value (e.g., `true`) instead of a valid string literal or `StacktraceOption` enum after upgrading to v5.0.0 or higher.
fix
Change the `displayStacktrace` option in your `SpecReporter` configuration to one of the allowed string values ('none', 'raw', 'pretty') or use the `StacktraceOption` enum (e.g., `displayStacktrace: StacktraceOption.PRETTY`).
Upgrade
Version history
7.0.0latest on npm
Audit
Dependencies
jasminerequiredThe core testing framework for which this package provides a reporter. Must be installed separately in the consuming project as a devDependency.
colorsrequiredProvides colorization for terminal output; direct runtime dependency since v5.0.1.
Agent activity
7 hits · last 30 days
node
6
Amazon
1
Resources