JavaScript Unit Testing with TDD, Jasmine and Karma

Originally published on TestProject – Test Automation Blog  JavaScript Unit Testing with TDD, Jasmine and Karma   In this article, we’ll introduce you to a tool combination which will make JavaScript unit testing so much easier. Jasmine and Karma combined will save you hours of testing. First, let’s understand what exactly are TDD, Jasmine and Karma. Test driven development (TDD) is one of the main, agile development techniques. The genius of TDD lies in writing your test’s code first, so it can guide your further implementations. This method provides you with an increased quality of code, improved bug detection and overall faster...

Read More

CRUD in Sails.js and Node.js

Disable Blueprints First of all you need to disable all existing blueprints in config/blueprints.js . JavaScript 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 /** * Blueprint API Configuration * (sails.config.blueprints) * * These settings are for the global configuration of blueprint routes and * request options (which impact the behavior of blueprint actions). * * You may also override any of these settings on a per-controller basis * by defining a '_config' key in your controller definition, and assigning it * a configuration object with overrides for the settings in this file. * A lot of the configuration options below affect so-called "CRUD methods", * or your controllers' `find`, `create`, `update`, and `destroy` actions. * * It's important to realize that, even if you haven't defined these yourself, as long as * a model exists with the same name as the controller, Sails will respond with built-in CRUD * logic in the form of a JSON API, including support for sort, pagination, and filtering. * * For more information on the blueprint API, check out: *!/documentation/reference/blueprint-api * * For more information on the settings in this file, see: *!/documentation/reference/sails.config/sails.config.blueprints.html * */ module.exports.blueprints = {   /***************************************************************************   *                                                                          *   * Action routes speed up the backend development workflow by               *   * eliminating the need to manually bind routes. When enabled, GET, POST,   *   * PUT, and DELETE routes will be generated for every one of a controller's *  ...

Read More

Create new Api in Sails.js

Create new Api JavaScript 1 sails generate api Product It will create a new Product model and ProductController file . Add Model Attributes JavaScript 12345678910111213141516171819 /** * Product.js * * @description :: TODO: You might write a short summary of how this model works and what it represents here. * @docs        :: */ module.exports = {   attributes: {    name : {     type : 'string'   },   qty :{     type : 'integer'   }  }};   Let me run the project now by using sails lift Shell 1 sails lift Product collection has been created successfully in MongoLab. Source Code   Want to learn more about Sails.js ? Please enroll into my course on Udemy: Node:js : Building Rest Apis with Sails.js for only $15 :…...

Read More

Node.js: Connecting Sails.js App to MongoLab

Signup MongoLab First of all you need to create a new account at MongoLab. After created account you need to create a new deployment in Mongolab. Make sure you have selected free sandbox You also need to create a new database with this new sandbox. Create a new User   To connect MongoLab with Sails.js . You need to create a new user . Create new Connection in Sails Now you have to create a new connection in sails.js app. First of all you need to install mongodb driver Shell 1 npm install --save sails-mongo Open your connections.js  file in Sails.js app. Create a new mongoLabServer connection object   To connect Sails.js app to MongoLab you need to use your mongo uri Shell 1 mongodb://<dbuser>:<dbpassword> After created connection you need to tell your default connection to sails.js app. Open models.js from config/models.js and add mongoLabServer connection to models object.   Run your sails project Shell 1 sails lift Your project will be running on PORT 1337 . You sails app has been connected to MongoLab   If you want to learn more about Sails.js and Node.js. I have created a new course Udemy. Here is the link of my course Nodejs: Building Rest Apis with...

Read More

Implement Lazy Loading in Angular 4

 Code     Demo Getting Setup I am going to use Angular-cli to create angular project. Installing angular cli Shell 1 npm install -g angular-cli Creating new project Shell 1 ng new lazy-demo I have divided this app into three angular module 1. App Module App module is a main module. This is our entry module 2. Customers Module Customers module is a feature module.This customer module will have the customer-list component . This customer-list component will fetch the customers from firebase database.I am going to use firebase database to get data from server. 3. Departments Module Departments module is also a feature...

Read More
  • 1
  • 2