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.
npm install jasmine-coreVerified import paths — ran on the pinned version, not inferred.
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.
Upgrade Node.js to v16 or higher for Jasmine v6.x, and v18 or higher for Jasmine v7.x.
Change `import Jasmine from 'jasmine-core';` to `import { Jasmine } from 'jasmine-core';` or `import * as Jasmine from 'jasmine-core';`.Use the configuration object passed to the `Jasmine` constructor or its methods to set timeout intervals and access environment specifics.
If `expectAsync` is critical, ensure your Jasmine configuration enables it or use `await expect()` for async matchers directly.
Refactor code to use `spyOn(object, 'method')`, `jasmine.createSpy('mySpy')`, or `jasmine.createSpyObj('MyObj', ['method1', 'method2'])`.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.
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.
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.
Ensure your Jasmine configuration explicitly enables `expectAsync` if you need it as a global, or refactor to use `await expect()` for async matchers directly.
No dependency data recorded yet.