What is the purpose of jasmine-node? - javascript

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?

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

Related

Can i migrate my Node based project to Deno?

Hello I am a frontEnd developer.
First, I don't know much about the runtime environment.
Is it possible to convert my project into Deno with Node?
Even if I change all of my code,
I'm not sure if the libraries I've received can run in a Deno environment.
(too many libs...) (React, Apollo, many many many)
And since the current webpack settings are very complex and difficult to understand, (And I understand very little about the build system.)
I am not sure if this can work in a Deno environment.
In my opinion, it seems impossible, I will only use Deno when working on a new project, Or wait for someone to create a migration guide.
What do you think about this?
Add
Obviously, it would be impossible if the libraries I used were not registered in the Deno repository.
And second, there seems to be a node compatibility issue.
Now i am sure that i can't covert it to deno.
Thanks
There is Denoify.
This tool takes as input a TypeScript codebase that was meant to target node and/or the web and spits out a modified version of the source files that are ready to be deployed as a Deno module.
It also helps to deploy on both NPM and deno.land/x
However, it is still under active development, not all node builtins are supported yet and you will probably have to make some changes here and there on your codebase to comply with the requirement Denoify sets.
Also, I am the author.
You're using many npm packages in your node project.Deno doesn't work with them.So either you'll wait to deno to be mature enough or you're gonna keep building your projects with node until that time.So i think if you want to take full advantage of deno, you should wait for deno to mature
Any code you write in pure JavaScript or TypeScript will work both in Node.js and Deno.
However, it's more than likely you have used Node.js-specific features in your current project. requires, calls to native Node.js APIs like http, util, and many others will not work in the Deno runtime.
Also, these kinds of Node.js-specific APIs are used in most Node.js libraries, so you'll have to do a complete rewrite to Deno.
I am not sure enough but as you have a Node.js project you should be using npm packages so until and unless those npm packages you use have alternative Deno packages it isn't possible if not then as #IsaToltar said to wait for it to be mature enough.
but if you can tell us what third-party npm packages you use then we might be able to find an alternative Deno package for that.
I hope it helps.
Deno now supports node-based projecs + NPM, it is considered to be stable, although still a work in progress.
To learn more, take a look at:
https://deno.land/manual#v1.29.2/node https://deno.land/manual#v1.29.2/node/how_to_with_npm https://deno.land/manual#v1.29.2/node/std_node

How can I configure popular JavaScript unit test frameworks to co-operate with Jenkins?

I want Jenkins to run JavaScript unit tests.
Although I came across different JavaScript unit test frameworks, like Jasmine or Tape, I cannot find any documentation on how to make them work and set-up their output to co-operate with Jenkins.
Can anyone point me to a documentation for Jasmine, Tape and other unit test frameworks, explaining on how to configure them properly to be triggered and evaluated by Jenkins?
There is nothing special to do with regards to Jenkins. You need to install the testing libraries as you normally would on the Jenkins executor nodes, and then you can use them as you normally use them from within your Jenkins job. Note that this may mean calling npm install from within your Jenkins job - this is pretty typical; you would do something similar whether you were using Python virtualenv, Ruby bundler, etc.

How to set up an automated testing environment for AngularJS

I have spent hours trying to set up an automated testing environment for my AngularJS applications that I can run from Maven (capturing results in Bamboo)
A Google search reveals frameworks galore, based on Jasmine, Karma and generic JavaScript frameworks.
But for some reason the installation of these never goes as described.
Can anyone just point me to a set of downloads that I can install manually to proper directories, that will just execute my unit tests?
I asked a similar question previously and got down checked and requests to close. If you need to check me down, please leave a reason, as I am besides myself with frustration trying to solve this, and I am sure there many other developers experiencing the same issue
Testing javascript is not a totally mature thing, so there isn't a great diversity of good tools for doing so. Jasmine and Karma are the current best ways of doing that.
Those tools are best managed using bower, which is a nodejs package. So you'll have to install, in this order:
nodejs
npm (node package manager)
bower (using npm)
jasmine and karma using bower
phantomjs, and whatever other dependencies your javascript needs (presumably angular)
Then you can run the tests.
I found this package for maven with some brief googling, but god knows how to set it up:
http://searls.github.io/jasmine-maven-plugin/
There are many tutorials on going through this process. You have to accept that these are currently the best tools for doing this and give it your best shot. If you post more specific issues regarding the 'installation that never goes as described' of jasmine and karma you will get assistance.
you can use for example yeoman or angular-seed. both will require nodejs and optionally ruby. both will set you with phantomjs, jasmine, karma, bower and many more. however i would avoid combining that build with maven. imho it's far from perfect. java tools will never be as good as native js tools for building js project. if you really want to combine the builds then use java only to call nodejs and nothing more

How do I integrate jasmine into mocha?

I have a large set of unit test written in jasmine-node for a Node project. I want to use Mocha for the expanded feature set but I'm pretty in bed with jasmine both for style and extensive use of spies. I have several helpers and custom code that is very jasmine dependent.
How can I use jasmine-node or the jasmine library as the framework while mocha is the testing engine? Can the two play nicely or do I have to rewrite my testing environment for mocha, chai, and sinon?
How can I use jasmine-node or the jasmine library as the framework while mocha is the testing engine?
What? Do you mean you want to code your tests against jasmine and then somehow run them in mocha? While I'm sure it's possible, it just sounds bizarre.
For a given suite of tests, it's one or the other. They have similar but different APIs so you have to choose one. Choosing BOTH in a single project is almost certainly poor judgement IMHO. Other than mocha's vastly superior async support, I can't see how you could justify using both when they are so closely related. It's just going to create a confusing annoyance for maintenance.
Suggestion: split your project apart into smaller, separate modules. Than you can port each of these smaller modules when the time is right if you want to migrate from jasmine to mocha.

testing nodejs modules, best tutorials, approaches?

I'm new to testing nodejs modules.
Is there a well organized tutorial out there that can get me going on testing the modules I've written in nodejs? I searched online, found some things but not sure what the best/most updated approach is to run tests on modules?
Thank you
There are many test frameworks available for node.js. I recommend mocha (highly) or jasmine-node as good starting places. nodeunit and vows are also widely used.
Other than that, this is a question better posed on google.com as it's not a specific programming question with a specific answer. This jasmine tutorial looks good and the jasmine-node docs will tell you how to run it inside node.js instead of the browser, which is straightforward.

Categories

Resources