{"id":11126,"library":"jasmine-spec-reporter","title":"Jasmine Spec Reporter","description":"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.","status":"maintenance","version":"7.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/bcaudan/jasmine-spec-reporter","tags":["javascript","jasmine","reporter","bdd","spec","protractor","typescript"],"install":[{"cmd":"npm install jasmine-spec-reporter","lang":"bash","label":"npm"},{"cmd":"yarn add jasmine-spec-reporter","lang":"bash","label":"yarn"},{"cmd":"pnpm add jasmine-spec-reporter","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"The core testing framework for which this package provides a reporter. Must be installed separately in the consuming project as a devDependency.","package":"jasmine","optional":false},{"reason":"Provides colorization for terminal output; direct runtime dependency since v5.0.1.","package":"colors","optional":false}],"imports":[{"note":"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.","wrong":"const SpecReporter = require('jasmine-spec-reporter')","symbol":"SpecReporter","correct":"import { SpecReporter } from 'jasmine-spec-reporter'"},{"note":"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.","symbol":"StacktraceOption","correct":"import { StacktraceOption } from 'jasmine-spec-reporter'"},{"note":"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.","symbol":"DisplayProcessor","correct":"import { DisplayProcessor } from 'jasmine-spec-reporter'"},{"note":"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.","symbol":"CustomReporterResult","correct":"import { CustomReporterResult } from 'jasmine-spec-reporter'"}],"quickstart":{"code":"import { SpecReporter, StacktraceOption } from 'jasmine-spec-reporter';\nimport * as Jasmine from 'jasmine'; // Ensure 'jasmine' package is installed\n\nconst runner = new Jasmine();\n\n// Clear any default reporters to avoid duplicate output\nrunner.env.clearReporters();\n\n// Add the SpecReporter with custom configuration\nrunner.env.addReporter(new SpecReporter({\n  spec: {\n    displayStacktrace: StacktraceOption.PRETTY, // Options: 'pretty', 'raw', 'none'\n    displayDuration: true,\n  },\n  suite: {\n    displayNumber: true,\n  },\n  summary: {\n    displayPending: false,\n    displayFailed: true,\n    displayDuration: true,\n  },\n  colors: {\n    success: 'green',\n    failure: 'red',\n    pending: 'yellow',\n  },\n  // For advanced customization, you can add custom processors:\n  // customProcessors: [new MyCustomDisplayProcessor()],\n}));\n\n// Define a simple test suite for demonstration purposes\nrunner.describe('A basic test suite', () => {\n  runner.it('should pass an assertion', () => {\n    runner.expect(true).toBe(true);\n  });\n\n  runner.it('should fail an assertion', () => {\n    runner.expect(1).toBe(2);\n  });\n\n  runner.pending('should be a pending test that is not run');\n});\n\n// Execute the tests (in a real scenario, this might be handled by a test runner)\nrunner.execute();","lang":"typescript","description":"Demonstrates how to install and configure `jasmine-spec-reporter` with a minimal Jasmine test suite, showcasing basic options like stacktrace display and color settings."},"warnings":[{"fix":"If extending `CustomReporterResult` in TypeScript, update your interface to reflect the `_jsr` nested property for duration information.","message":"The `CustomReporterResult` interface signature was updated to fix collisions with new Jasmine properties. Specifically, `duration` property moved from the top level to `_jsr?: { formattedDuration?: string }`.","severity":"breaking","affected_versions":">=7.0.0"},{"fix":"Update custom display processors to use `this.theme.successful('OK ')` instead of `String.prototype` extensions for applying colors.","message":"String 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.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"Update your configuration to use `StacktraceOption.PRETTY` (or `RAW`, `NONE`) instead of a boolean value for `displayStacktrace`.","message":"The `displayStacktrace` option in the reporter configuration changed from a boolean to an enum (`StacktraceOption.NONE`, `StacktraceOption.RAW`, `StacktraceOption.PRETTY`).","severity":"breaking","affected_versions":">=5.0.0"},{"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`).","message":"The `DisplayProcessor` methods signature in TypeScript changed from using `String` wrapper objects to `string` primitive types for log parameters and return values.","severity":"breaking","affected_versions":">=4.0.0"},{"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`).","message":"The `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.","severity":"gotcha","affected_versions":">=2.x"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"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;`.","cause":"Type mismatch between `jasmine-spec-reporter`'s `SpecReporter` and `@types/jasmine`'s `CustomReporter` interface, often due to differing versions.","error":"TS2345: Argument of type 'SpecReporter' is not assignable to parameter of type 'CustomReporter'."},{"fix":"Modify your custom `DisplayProcessor` to use the injected `this.theme` object for colorization, e.g., `return this.theme.successful('OK ') + log;`.","cause":"Attempting to use deprecated String prototype extensions for applying colors within custom display processors after upgrading to v6.0.0 or higher.","error":"Property 'successful' does not exist on type 'String'. Did you mean 'toLowerCase'?"},{"fix":"Add `import { StacktraceOption } from 'jasmine-spec-reporter';` to your file where `SpecReporter` is configured.","cause":"Using `StacktraceOption.PRETTY` (or `RAW`, `NONE`) without importing `StacktraceOption` from `jasmine-spec-reporter`.","error":"TypeError: Cannot read properties of undefined (reading 'PRETTY')"},{"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`).","cause":"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.","error":"Error: 'displayStacktrace' must be one of 'none', 'raw', 'pretty'"}],"ecosystem":"npm"}