Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the purpose of jasmine-node?

I can run my specs with either jasmine-node or just jasmine. They both run my specs. So, what value does jasmine-node add? The readme says:

This node.js module makes the wonderful Pivotal Lab's jasmine spec framework available in node.js. https://github.com/mhevery/jasmine-node/blob/master/README.md

I don't understand. My app runs on node, my specs require node modules .. so when I run jasmine, I'm already using both node and jasmine. What does jasmine-node add?

I specifically am not asking for opinions about why jasmine-node is your favorite, or recommendations of other libraries. I only want to know, what is the purpose of jasmine-node?

like image 477
Jared Beck Avatar asked Nov 17 '15 21:11

Jared Beck


People also ask

For what purpose node is used?

Node. js is commonly used to develop real-time applications, also known as RTAs. Its asynchronous, event-driven nature, allows it to handle heavy input-output operations, which makes it much easier for Node. js developers to achieve the level of performance users have come to expect from modern real-time applications.

Why is node so popular?

Node. js can handle many concurrent requests. This is the main reason it quickly became popular among developers and large companies. It can handle multiple requests simultaneously without straining the server.

What is the use of Jasmine framework?

Jasmine Framework is an open-source JavaScript testing framework. It is a behavior-driven (BDD), development-inspired framework that is independent of any other frameworks. It is used for unit testing of both synchronous and asynchronous JavaScript test scenarios.

What is Jasmine npm?

The jasmine module is a command line interface and supporting code for running Jasmine specs under Node. The core of jasmine lives at https://github.com/jasmine/jasmine and is jasmine-core in npm.


1 Answers

The subtitle of jasmine-node is a good answer to your question:

DOM-less simple JavaScript BDD testing framework for Node

Let's go and look at the different parts of the answer:

DOM-less simple testing framework

jasmine is a JS testing tool. At the beginning JS was just for browsers. To give an output inside the browser there is this DOM Model, which is not so easy to use. Node.js gives you the possibility to run JS also on a server. On the server-side there is no DOM. To make things faster and easier you don't need a DOM implementation for your testing tool, when it just runs inside node.js

Jasmine itself is independent of a browser, so that is an intention for both jasmine and jasmine-node.

for Node

This is easy - jasmine-node is just for node and not for browser JS.

But behind that part there is the main purpose. Because the requirements between a brwoser test and a node.js test are totaly different. Because jamsine supports both ways it can not have all features, which are possible with node. If you look at the possible arguments at the documentation you see that there are much more options inside the CLI of jasmine-node. Some of the most interesting features are maybe:

  • Test a file automaticaly, when it changes
  • test coffeescript files directly

So to give you an answer to your question:

What is the purpose of jasmine-node?

jasmine-node provides you more CLI options for you tests. It can make some work automaticaly and it uses more of the node functions to provide that. So the future way for jasmine-node will be in providing more functions, which are just able to implement, when you just test on node.js

like image 172
apxp Avatar answered Oct 02 '22 08:10

apxp