GETTING STARTED

Jasmine for Node.js

Add Jasmine to your package.json

npm install --save-dev jasmine

Initialize Jasmine in your project

npx jasmine init

Set jasmine as your test script in your package.json

"scripts": { "test": "jasmine" }

Run your tests

npm test

More Information

Jasmine for Browsers

Add Jasmine to your package.json

npm install --save-dev jasmine-browser-runner jasmine-core

Initialize Jasmine in your project

npx jasmine-browser-runner init

Set jasmine as your test script in your package.json

"scripts": {"test": "jasmine-browser-runner runSpecs"}

Run your tests

npm test

More Information

Jasmine Standalone

The standalone distribution provides a simple way to run your specs in a web browser. You can download it from the releases page.

Included is a sample app and sample specs. Open SpecRunner.html and run the included specs. Both the source files and their respective specs are linked in the <head> of the SpecRunner.html.

To start using Jasmine, replace the source/spec files with your own. Then load the SpecRunner.html in your favorite browser.

You don't need a web server to run the standalone distribution, but it helps. Some browsers limit the error information that they provide to scripts running from file:// URLs, and this can make it harder to debug uncaught exceptions and unhandled promise rejections. If that's a concern, consider using a simple web server like the one provided by the serve package.

More Information