Generated by GPT-5-mini| Jasmine (JavaScript testing) | |
|---|---|
| Name | Jasmine |
| Developer | Pivotal Software |
| Released | 2010 |
| Programming language | JavaScript |
| Operating system | Cross-platform |
| License | MIT License |
Jasmine (JavaScript testing)
Jasmine is a behavior-driven development testing framework for JavaScript designed to run on Node.js and in web browsers. Inspired by RSpec and contemporaneous with QUnit and Mocha (software), Jasmine provides a clean syntax for writing unit tests and spies without requiring a DOM or a particular module loader such as RequireJS or ES6 modules. It is used in conjunction with continuous integration systems like Jenkins and Travis CI and integrates with editors such as Visual Studio Code and WebStorm.
Jasmine was created in 2010 by programmer Pivotal engineers influenced by testing culture at Pivotal Labs and practices advocated in Extreme Programming. Early releases aimed to provide a standalone test framework alternative to QUnit used by jQuery and to adopt the readable style of RSpec from the Ruby on Rails community. Over time Jasmine received contributions from developers associated with Pivotal Tracker and integrated concepts from other projects like Sinon.js and Karma (test runner). Major milestones include adoption by enterprise products developed at IBM and Google and inclusion in tooling supported by Microsoft and GitHub.
Jasmine's notable features emphasize simplicity and independence. The framework offers a BDD-style syntax similar to RSpec with global functions such as describe and it, built-in matchers for assertions, and support for asynchronous specifications using done callbacks or Promises compatible with ECMAScript 2015. Jasmine includes a spy system for mocking and spying on functions inspired by techniques used in Sinon.js and integrates with test runners such as Karma (test runner) and Jest (software). It ships without external dependencies, enabling use alongside module systems like CommonJS and bundlers such as Webpack and Browserify.
Jasmine's architecture centers on a lightweight core that exposes a declarative API. The test runner organizes specifications into suites via describe blocks and specs via it blocks, producing hierarchical reporting consumed by reporters that can target consoles used by Bash shells or CI dashboards in CircleCI and Travis CI. Matchers such as toEqual, toBe, and toContain implement deep equality logic similar to algorithms used in Lodash and Underscore.js for structural comparisons. The spy and mock subsystem instruments functions and integrates with asynchronous control flows from Promise implementations standardized in ECMAScript 2015, enabling time-based behavior testing when combined with helpers from Sinon.js or fake timers provided by frameworks like Jest (software).
Basic usage demonstrates describe/it structure and expectations. A simple spec checks a function exported by modules using loaders like RequireJS or ES6 modules transpiled by Babel (transpiler) and bundled via Webpack: - Define suites with describe, create specs with it, assert with expect and matchers such as toBe and toEqual. - Use beforeEach and afterEach hooks to prepare state, influenced by setup patterns from JUnit and NUnit. - For asynchronous code, return a Promise or use the done callback to integrate with async/await syntax introduced in ECMAScript 2017. Examples are commonly run in browsers automated by Selenium (software) or headless environments like Puppeteer driven by Chromium for end-to-end test pipelines.
Jasmine is often compared to Mocha (software), QUnit, Tape (software), and Jest (software). Unlike Mocha, Jasmine includes built-in matchers and a spy library, reducing dependency management compared with setups that combine Mocha with Chai and Sinon. Compared with Jest, which bundles assertion, mocking and snapshot features and is maintained by Meta Platforms, Inc. (formerly Facebook), Jasmine focuses on a smaller, dependency-free core and broader compatibility with diverse runners. QUnit, originating from jQuery, emphasizes simplicity for DOM-centric tests, while Jasmine targets both browser and server environments and mirrors the BDD idiom from RSpec.
Jasmine integrates with a broad ecosystem: test runners like Karma (test runner), CI platforms like Jenkins and Travis CI, and code coverage tools such as Istanbul (software). Editors and IDEs including Visual Studio Code, WebStorm, and Sublime Text offer plugins or extensions for running specs and viewing results. Bundlers and transpilers (Webpack, Rollup (software), Babel (transpiler)) enable Jasmine to test modern ECMAScript features, while adapters exist for task runners like Gulp and Grunt to incorporate tests into build pipelines. Reporting plugins export results in formats consumable by JUnit-style reporters for enterprise dashboards.
Jasmine has been adopted by web and enterprise projects across organizations such as Google, IBM, and startups incubated at Pivotal Labs. It has been used to test frameworks and libraries integrating with AngularJS and tools in the Node.js ecosystem, and appears in open source projects hosted on GitHub and managed via npm (software registry). Notable uses include client-side testing in applications built with Angular (software) and legacy codebases migrated from jQuery-centric test suites. The framework's enduring presence is visible in educational resources and testing curricula at coding schools influenced by Pivotal Labs practices and in corporate CI workflows at firms using Travis CI and CircleCI.
Category:JavaScript testing frameworks