{"id":11123,"library":"jasmine-core","title":"Jasmine Core Testing Framework","description":"jasmine-core is the foundational, standalone JavaScript testing framework that underpins the broader Jasmine ecosystem. It provides the core APIs for writing specs (tests), matchers, and the test runner logic itself. While `jasmine-core` can be used directly for programmatic testing in both browser and Node.js environments, it's more commonly consumed as a dependency by higher-level packages like `jasmine` (for CLI execution) or `jasmine-browser-runner` for a more integrated experience. The current stable version is 6.2.0, with a major version 7.0.0-pre.0 already in pre-release. Jasmine maintains a regular release cadence, typically releasing minor and patch versions every 1-2 months, and major versions annually or bi-annually. Its key differentiators include its behavior-driven development (BDD) syntax, built-in assertion library, and lack of external dependencies for core functionality, making it a simple, self-contained solution for unit and integration testing.","status":"active","version":"6.2.0","language":"javascript","source_language":"en","source_url":"https://github.com/jasmine/jasmine","tags":["javascript","test","testing","jasmine","tdd","bdd"],"install":[{"cmd":"npm install jasmine-core","lang":"bash","label":"npm"},{"cmd":"yarn add jasmine-core","lang":"bash","label":"yarn"},{"cmd":"pnpm add jasmine-core","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Primarily for programmatic setup. For ESM, direct import of `jasmine` as a named export is needed since v6. For CJS, `require('jasmine-core').getJasmineRequireObj()` is closer to the core object but still not directly `jasmine`.","wrong":"const jasmine = require('jasmine-core');","symbol":"jasmine","correct":"import { jasmine } from 'jasmine-core';"},{"note":"Used to initialize Jasmine globals for browser environments. Often implicitly called by `jasmine-browser-runner`.","wrong":"import bootJasmine from 'jasmine-core/lib/boot.js';","symbol":"bootJasmine","correct":"import { bootJasmine } from 'jasmine-core';"},{"note":"This is primarily a CommonJS export for internal use or advanced custom runners. Direct ESM import is generally not recommended as the primary interaction pattern for most users, and its usage differs from typical named exports.","wrong":"import { getJasmineRequireObj } from 'jasmine-core';","symbol":"getJasmineRequireObj","correct":"const { getJasmineRequireObj } = require('jasmine-core');"}],"quickstart":{"code":"import Jasmine from 'jasmine';\n\nconst jasmine = new Jasmine();\n\n// Configure Jasmine to use a custom reporter or default options\njasmine.loadConfig({\n  spec_dir: 'spec',\n  spec_files: [\n    '**/*[sS]pec.js'\n  ],\n  helpers: [\n    'helpers/**/*.js'\n  ],\n  random: false,\n  seed: null,\n  stopSpecOnExpectationFailure: false,\n  failFast: false\n});\n\n// Add a simple spec file example (usually in a 'spec' directory)\n// This would typically be in a separate file, e.g., 'spec/my-spec.js'\n// describe('My Feature', () => {\n//   it('should do something', () => {\n//     expect(true).toBe(true);\n//   });\n// });\n\n// For programmatic use, you can add a simple spec directly if not loading from files\n// For a more complete programmatic example, you'd typically load files.\n// Here's a placeholder for loading specs:\n// jasmine.addSpecFile('spec/my-spec.js');\n\njasmine.onComplete(function(passed) {\n  if(passed) {\n    console.log('All specs have passed');\n  } else {\n    console.error('At least one spec has failed');\n  }\n});\n\njasmine.execute();\n","lang":"javascript","description":"This quickstart demonstrates how to programmatically configure and run Jasmine tests using the `Jasmine` class from the `jasmine` package (which wraps `jasmine-core`). It shows basic configuration loading and execution with a completion callback."},"warnings":[{"fix":"Upgrade Node.js to v16 or higher for Jasmine v6.x, and v18 or higher for Jasmine v7.x.","message":"Jasmine v6.0.0 dropped support for Node.js 14. Projects must now target Node.js 16 or newer. Node.js 18+ is required for the upcoming v7.0.0.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"Change `import Jasmine from 'jasmine-core';` to `import { Jasmine } from 'jasmine-core';` or `import * as Jasmine from 'jasmine-core';`.","message":"With Jasmine v6.0.0, the `default` export for `jasmine-core` was removed for ESM. You must now use named exports for ESM imports.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"Use the configuration object passed to the `Jasmine` constructor or its methods to set timeout intervals and access environment specifics.","message":"`jasmine.DEFAULT_TIMEOUT_INTERVAL` and `jasmine.getEnv()` are deprecated in v6.0.0. While they still work, direct access is discouraged.","severity":"deprecated","affected_versions":">=6.0.0"},{"fix":"If `expectAsync` is critical, ensure your Jasmine configuration enables it or use `await expect()` for async matchers directly.","message":"Global `expectAsync` is no longer available by default in Jasmine v6.0.0. It must be explicitly enabled if required.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"Refactor code to use `spyOn(object, 'method')`, `jasmine.createSpy('mySpy')`, or `jasmine.createSpyObj('MyObj', ['method1', 'method2'])`.","message":"`jasmine.Spy` constructor was removed in v6.0.0. Spies should be created using `spyOn`, `createSpy`, or `createSpyObj`.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"If strict non-null/non-undefined checks are needed, use `expect(value).not.toBeNull()` or `expect(value).not.toBeUndefined()` in addition to `jasmine.anything()` or create a custom matcher.","message":"The `jasmine.anything()` matcher now returns `true` for `null` and `undefined` in v6.0.0, which was not the case in previous versions.","severity":"gotcha","affected_versions":">=6.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Ensure your `package.json` `type` field is correctly set (e.g., `\"type\": \"module\"` for ESM files, or remove it for CJS). Use `import` statements for ESM and `require` for CJS. Verify the package is installed.","cause":"Attempting to `require('jasmine-core')` in an ESM context or `import` in CJS, or incorrect module resolution.","error":"Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jasmine-core' imported from ..."},{"fix":"Instead of `jasmine.getEnv()`, configure Jasmine via the `Jasmine` class instance (e.g., `new Jasmine().configure(...)`) or a configuration file. If migrating, consider using `jasmine-browser-runner` or the `jasmine` CLI package which abstract this.","cause":"Attempting to access `jasmine.getEnv()` directly after upgrading to Jasmine v6.x, where it's deprecated.","error":"TypeError: jasmine.getEnv is not a function"},{"fix":"Ensure your Jasmine configuration explicitly enables `expectAsync` if you need it as a global, or refactor to use `await expect()` for async matchers directly.","cause":"Attempting to use `expectAsync()` globally after upgrading to Jasmine v6.x without explicitly enabling it.","error":"TypeError: expectAsync is not a function"}],"ecosystem":"npm"}