jasmine
Jasmine is a behavior-driven development testing framework for JavaScript that does not depend on any other JavaScript framework and does not require a DOM. Cre…
Installation
npm install -D jasmine
yarn add -D jasmine
pnpm add -D jasmine
Import
// jasmine uses globals: describe, it, expect
Quick Example
describe('Calculator', () => {
it('should add two numbers', () => {
expect(1 + 2).toBe(3);
});
it('should handle negative numbers', () => {
expect(-1 + 1).toBe(0);
});
});About jasmine
Jasmine is a behavior-driven development testing framework for JavaScript that does not depend on any other JavaScript framework and does not require a DOM. Created in 2010, Jasmine was one of the first BDD-style testing frameworks for JavaScript and heavily influenced Jest's API design. Jasmine provides describe/it blocks for organizing tests, a rich set of built-in matchers (toBe, toEqual, toBeTruthy, toContain, toThrow, etc.), spies for tracking function calls and controlling behavior, a clock mock for testing time-dependent code, and async test support. Jasmine tests are self-contained — the framework includes everything needed for testing without requiring external assertion or mocking libraries. The spy system allows creating standalone spies, spying on existing methods, and configuring return values or fake implementations. Jasmine's custom matcher system lets teams define domain-specific assertions that improve test readability. While Jest has largely replaced Jasmine in the React ecosystem, Jasmine remains the default test framework for Angular projects (through Karma) and is widely used in enterprise JavaScript applications. The framework's stability and minimal dependency footprint make it suitable for environments with strict dependency policies.
Quick Facts
| Package | jasmine |
| Category | Testing |
| Weekly Downloads | 3M+ |
| License | MIT |
| Install | npm install -D jasmine |
Related Packages
Jest is a delightful JavaScript testing framework with a focus on simplicity, created by Facebook. I…
Mocha is a feature-rich JavaScript test framework that runs on Node.js and in the browser, providing…
Chai is a BDD/TDD assertion library for Node.js and the browser that pairs with any JavaScript testi…
Sinon.js provides standalone test spies, stubs, and mocks for JavaScript that work with any test fra…
Browse npm Packages by Category
Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.