85% Discount for all November
Testing
Jasmine is the most popular JS library for unit testing web apps.
Jasmine is a very popular JavaScript behavior-driven development (In BDD, you write tests before writing actual code) framework for unit testing JavaScript applications. It provides utilities that can be used to run automated tests for both synchronous and asynchronous code.
Jasmine has many features such as:
• It’s fast and has low overhead and no external dependencies.
• Its batteries included a library and offer everything you need for testing your code.
• It’s available both for Node and the browser.
• It can be used with other languages like Python and Ruby.
• It does not require the DOM.
• It provides a clean and easy-to-understand syntax and also a rich and straightforward API.
Jasmine is an open-source tool that’s available under the permissive MIT license. As of this writing, the latest major version is Jasmine 3.0 which provides new features and some breaking changes. The 2.99 release of Jasmine will provide different deprecation warnings for suites that have different behavior in version 3.0 which will make it easy for developers to migrate to the new version.
Using Jasmine
You can use Jasmine in many different ways:
• in the old way by including both the Jasmine core and your test files using a <script> tag,
• as a CLI tool using Node.js,
• as a library in Node.js,
• as a part of a build system like Gulp.js or Grunt.js via grunt-contrib-jasmine and gulp-jasmine-browser
Jasmine comes with an inbuilt test runner. Jasmine tests can run browser tests by including a simple SpecRunner.html file or by using it as a command-line test runner supported for various languages like Node.js, Python, Ruby
Jasmine does not require the project to have a specific directory layout, but it does use a configuration file to specify where to find tests. The default, conventional project structure created by “jasmine init” puts all Jasmine code into a “spec” directory, which contains “*spec.js” files for tests, helpers that run before specs, and a support directory for config. The JASMINE_CONFIG_PATH environment variable can be set to change the config file used. (The default config file is spec/support/jasmine.json.)
Friday, Apr 9, 2021