Jasmine
Jasmine: A lightweight JavaScript testing framework for browsers and Node.js
About Jasmine
Jasmine is a behavior-driven development framework for testing JavaScript code. It features a clean syntax, zero dependencies, and runs seamlessly in both browsers and Node.js environments.
FAQ
Jasmine follows semver as defined by the Semantic Versioning Specification. Major versions are reserved for breaking changes, while most releases are minor versions. The jasmine package's major and minor versions match jasmine-core, but patch versions are handled separately. The jasmine-browser-runner package has its own versioning strategy and declares jasmine-core as a peer dependency.
Jasmine supports a rolling window of Node and browser versions. Fully supported versions include current, active, and maintenance LTS releases of Node, and the latest versions of evergreen browsers. Older versions are supported on a best-effort basis, while unsupported versions are not tested. Check the release notes for specific support details.
You can add the script's URL to the srcFiles array in your jasmine-browser.json or jasmine-browser.js file. For example: srcFiles: [ "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.0/jquery.min.js", "**/*.js" ]
Yes. If using the standalone distribution, use . If using the jasmine NPM package, files are treated as ES modules if the package has "type": "module" in package.json or if filenames end in .mjs. jasmine-browser-runner loads scripts as ES modules if filenames end in .mjs, which can be overridden with the esmFilenameExtension configuration property.
Jasmine allows multiple expectation failures to help identify all issues at once. To stop at the first failure, set the oneFailurePerSpec option to true. For the standalone distribution, edit boot.js or use the UI option. For the jasmine NPM package, set stopSpecOnExpectationFailure to true in your config file.
Enable the failSpecWithNoExpectations option. For the standalone distribution, add it to the config object in boot.js. For the jasmine NPM package, add it to your config file. Note that this only ensures at least one expectation exists, not that the spec is correct.
karma-jasmine is unmaintained and depends on jasmine-core 4.x. To use newer features, migrate to jasmine-browser-runner or web-test-runner-jasmine. Alternatively, override karma-jasmine's dependency in package.json, but this only works up to jasmine-core 6.x.
Use throwUnless instead of expect. For example: await waitFor(function() { throwUnless(myDialogElement).toHaveClass('open'); });
Alternatives to consider
Community ratings & full listBadges
Promote Jasmine giving it more exposure, by adding these badges to your website, documentation, or product listing. Each badge links back to Jasmine page on Webfolio.
<a href="https://www.webfolio.to/tools/jasmine?utm_source=badge&utm_campaign=badge" target="_blank" rel="noopener noreferrer"><img src="https://www.webfolio.to/badges/featured_color.svg" alt="Featured on Webfolio" style="max-width: 150px" /></a>
Categories
Claim this tool
Are you the founder? Claim your profile to update details and track views.