{"id":11127,"library":"jasmine","title":"Jasmine CLI","description":"The `jasmine` package provides a command-line interface (CLI) and supporting utilities for running Jasmine Behavior Driven Development (BDD) tests in Node.js environments. As of its current stable version 6.2.0, this package acts as a runner for `jasmine-core`, which is the actual testing framework. Jasmine is known for its clean and easy-to-understand syntax, requiring no DOM or external JavaScript frameworks, making it suitable for a wide range of JavaScript projects. The project maintains an active release cadence, with minor and patch updates frequently, and major versions introducing significant changes every few months. It is compatible with both ES modules and CommonJS modules and officially supports Node.js versions 20, 22, and 24, with best-effort support for environments past their end-of-life.","status":"active","version":"6.2.0","language":"javascript","source_language":"en","source_url":"https://github.com/jasmine/jasmine-npm","tags":["javascript","test","testing","jasmine","tdd","bdd"],"install":[{"cmd":"npm install jasmine","lang":"bash","label":"npm"},{"cmd":"yarn add jasmine","lang":"bash","label":"yarn"},{"cmd":"pnpm add jasmine","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"This package is a CLI wrapper for the core Jasmine testing framework.","package":"jasmine-core","optional":false}],"imports":[{"note":"The `Jasmine` class is used for programmatic configuration and execution of tests. Both ESM and CommonJS `require()` are supported for this import.","wrong":"const Jasmine = require('jasmine'); // For CommonJS in ESM context without appropriate config","symbol":"Jasmine","correct":"import Jasmine from 'jasmine';"},{"note":"These are global functions provided by the Jasmine test runner and are available in test files without explicit imports. For TypeScript, install `@types/jasmine` for global type definitions.","symbol":"describe, it, expect","correct":"/* No explicit import needed in spec files */"},{"note":"Use type imports for the configuration object schema when working with TypeScript. The `jasmine.json` file dictates runtime configuration.","symbol":"Config","correct":"import type { Config } from 'jasmine';"}],"quickstart":{"code":"/* src/greeter.ts */\nexport function greet(name: string): string {\n  return `Hello, ${name}!`;\n}\n\n/* spec/greeter.spec.ts */\nimport { greet } from '../src/greeter';\n\ndescribe('Greeter', () => {\n  it('should return a greeting with the given name', () => {\n    expect(greet('World')).toEqual('Hello, World!');\n  });\n\n  it('should handle empty names gracefully', () => {\n    expect(greet('')).toEqual('Hello, !');\n  });\n\n  it('should support custom matchers if configured', () => {\n    // This test assumes a custom matcher 'toBeGreeting' is set up\n    // expect('Hello, Jasmine!').toBeGreeting();\n    expect(greet('Tester')).toContain('Tester');\n  });\n});\n\n/* Terminal commands */\n// 1. Install Jasmine\nnpm install --save-dev jasmine\n\n// 2. Initialize Jasmine project (creates spec/support/jasmine.json)\nnpx jasmine init\n\n// 3. Run tests\nnpx jasmine\n","lang":"typescript","description":"Demonstrates setting up Jasmine, writing a basic spec, and running tests via the CLI."},"warnings":[{"fix":"Upgrade your Node.js environment to version 20, 22, or 24.","message":"Jasmine v6.0.0 dropped support for Node.js versions older than 20. Projects running on Node.js 18 or earlier will encounter issues.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"If using `ConsoleReporter` programmatically, install `@jasminejs/reporters` and update your imports accordingly. For example, `import { ConsoleReporter } from '@jasminejs/reporters';`","message":"The `ConsoleReporter` was moved from the `jasmine` package to `@jasminejs/reporters` in v6.0.0. Direct imports or references to `ConsoleReporter` from `jasmine` will break.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"Consolidate your Jasmine configuration into a single `jasmine.json` file or use programmatic configuration via the `Jasmine` class to manage multiple configurations explicitly.","message":"With Jasmine v6.0.0, if multiple configuration files are present, only the first one is loaded. This changes previous behavior where multiple configs might have been merged.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"Refactor code to use documented public APIs. Avoid relying on internal Jasmine structures that were not explicitly exposed for public consumption.","message":"Jasmine-core v6.0.0 removed private APIs from its global namespace. Relying on undocumented or internal APIs will cause breakage, as these were never guaranteed to be stable.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"For Karma users outside Angular, consider migrating to alternatives like `jasmine-browser-runner` or `web-test-runner`. Angular users should consult Angular documentation for future Jasmine support.","message":"Jasmine v6.x emits deprecation warnings when used with `karma-jasmine` and other legacy Angular tools. Jasmine v7.0 will drop compatibility with these tools entirely.","severity":"deprecated","affected_versions":">=6.0.0"},{"fix":"Ensure your project uses a currently supported Node.js Long Term Support (LTS) release for reliable operation and continued compatibility.","message":"Jasmine only officially supports specific Node.js versions (20, 22, 24). Environments past end-of-life or odd-numbered Node versions are supported on a best-effort basis and may be dropped in future minor releases if support becomes impractical.","severity":"gotcha","affected_versions":">=5.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Run your tests using `npx jasmine` (or `npm test` if configured) instead of `node your-spec-file.js`. Ensure Jasmine is correctly installed and initialized (`npx jasmine init`).","cause":"This error occurs when a test file using Jasmine's global functions (`describe`, `it`, `expect`) is run directly with `node` instead of through the `jasmine` CLI or a configured test runner.","error":"ReferenceError: describe is not defined"},{"fix":"Install the Jasmine type definitions: `npm install --save-dev @types/jasmine`. Ensure your `tsconfig.json` includes `jasmine` in the `types` array or that `typeRoots` is correctly configured to find `@types` packages.","cause":"When using TypeScript, the global types for Jasmine's testing functions (`describe`, `it`, `expect`) are missing.","error":"TS2304: Cannot find name 'describe'"}],"ecosystem":"npm"}