Jasmine
Jasmine: A lightweight JavaScript testing framework for browsers and Node.js
À propos de 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 à considérer
Voir toutes les alternativesBadges
Faites la promotion de Jasmine et donnez-lui plus de visibilité en ajoutant ces badges à votre site web, votre documentation ou votre fiche produit. Chaque badge renvoie vers la page de Jasmine sur 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="Mis en avant sur Webfolio" style="max-width: 150px" /></a>
Catégories
Revendiquer cet outil
Vous êtes le fondateur ? Revendiquez votre profil pour mettre à jour les détails et suivre les vues.