How to Install and Configure Jasmine
Learn to install, configure, and run Jasmine locally.
Installing and running jasmine
If you’d like to run the examples locally, read ahead.
As a first step, install Node.js and npm.
Follow these steps to install and initialize Jasmine. Use the terminal below to run each of the following commands:
npm install --save-dev jasmine
installs the Jasmine npm package.mkdir spec
creates a folder for Jasmine config.npx jasmine init
initializes a standard Jasmine folder structure and config file: spec/support/jasmine.jsonnpx jasmine
runs Jasmine using npx.
Expected result
Randomized with seed 81352
Started
No specs found
Finished in 0.004 seconds
Incomplete: No specs found
This shows that Jasmine has been successfully installed and initialized.
It also shows what random seed has been used in case we’d like to repeat the exact same tests run. See Jasmine docs for more information.
It searches for .spec.js
files under the /src/ folder
by default. That can be changed in the spec/support/jasmine.json
file.
There are no test files in this environment yet, resulting in the No specs
found.
Add a test
To demonstrate ...