Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run Jasmine tests on Node.js from command line

How do I run Jasmine tests on Node.js from command line? I have installed jasmine-node via npm and written some tests. I want to run tests inside the spec directory and get results in the terminal, is this possible?

like image 814
PaolaJ. Avatar asked Jan 27 '14 21:01

PaolaJ.


People also ask

How do I run a node script from the command line?

You can Run your JavaScript File from your Terminal only if you have installed NodeJs runtime. If you have Installed it then Simply open the terminal and type “node FileName. js”. If you don't have NodeJs runtime environment then go to NodeJs Runtime Environment Download and Download it.


1 Answers

This should get you going quickly:

  1. install Node.js (obviously).
  2. Next install Jasmine. Open a command prompt and run:

    npm install -g jasmine

  3. Next, cd to any directory and set up an example 'project':

    jasmine init
    jasmine examples

  4. Now run your unit tests:

    jasmine

If your jasmine.json file is somewhere else besides spec/support/jasmine.json, simply run:

jasmine JASMINE_CONFIG_PATH=relative/path/to/your/jasmine.json

For more info see:

  • https://www.npmjs.com/package/jasmine
  • http://jasmine.github.io/2.2/node.html
like image 94
user64141 Avatar answered Sep 19 '22 12:09

user64141