Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Node.js Blueprints

You're reading from   Node.js Blueprints Develop stunning web and desktop applications with the definitive Node.js

Arrow left icon
Product type Paperback
Published in Jun 2014
Publisher
ISBN-13 9781783287338
Length 268 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Krasimir Stefanov Tsonev Krasimir Stefanov Tsonev
Author Profile Icon Krasimir Stefanov Tsonev
Krasimir Stefanov Tsonev
Arrow right icon
View More author details
Toc

Table of Contents (14) Chapters Close

Preface 1. Common Programming Paradigms FREE CHAPTER 2. Developing a Basic Site with Node.js and Express 3. Writing a Blog Application with Node.js and AngularJS 4. Developing a Chat with Socket.IO 5. Creating a To-do Application with Backbone.js 6. Using Node.js as a Command-line Tool 7. Showing a Social Feed with Ember.js 8. Developing Web App Workflow with Grunt and Gulp 9. Automate Your Testing with Node.js 10. Writing Flexible and Modular CSS 11. Writing a REST API 12. Developing Desktop Apps with Node.js Index

Using Jasmine


Jasmine is a framework to test the JavaScript code. It is available as a Node.js module and also as a library, which we can use in the browser. It comes with its own assertion methods.

Installing Jasmine

We are going to use the Node.js version of the framework. It's a module, so it can be installed via the Node.js package manager, npm, as shown in the following code line:

npm install jasmine-node -g

The preceding command will set up Jasmine globally, so we can run jasmine-node in every directory of our choice. The tests could be organized into different files placed in one folder or in subfolders. The only requirement is to end the filenames with spec.js, for example, testing-payments.spec.js or testing-authorization.spec.js.

Defining the module for testing

Before we write the actual test, let's define the application we want to build. Let's say we need a Node.js module that reads a file and finds specific words inside it. The following is the basic file structure that we are starting...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime