JavaScript for Line of Business Applications
596.1K views | +0 today
Follow
JavaScript for Line of Business Applications
Keeping track of current JavaScript Frameworks that help design your clientside Business Logic Layers.
Curated by Jan Hesse
Beam to my Inbox:
Your new post is loading...
Your new post is loading...

Popular Tags - Filter using the Funnel

Current selected tag: 'Sinon'. Clear
Scoop.it!

An Introduction To Unit Testing In AngularJS Applications

An Introduction To Unit Testing In AngularJS Applications | JavaScript for Line of Business Applications | Scoop.it

One of the reasons for AngularJS’ success is its outstanding ability to be tested. It’s strongly supported by Karma (the spectacular test runner written by Vojta Jína) and its multiple plugins. Karma, combined with its fellows MochaChai and Sinon, offers a complete toolset to produce quality code that is easy to maintain, bug-free and well documented.

Tests must define the code’s API. This is the one principle that will guide us through this journey. An AngularJS application is, by definition, composed of modules. The elementary bricks are materialized by different concepts related to the granularity at which you look at them. At the application level, these bricks are AngularJS’ modules. 

No comment yet.
Scoop.it!

AngularJS Unit Testing - For Real, Though

AngularJS Unit Testing - For Real, Though | JavaScript for Line of Business Applications | Scoop.it

This article is written for intermediate to advanced developers using AngularJS to build production applications, who would like to reduce some of the pain of testing. It is my hope that feeling secure in testing workflow will enable the reader to practice a TDD workflow and build a more solid app.

No comment yet.
Scoop.it!

Node.js Handbook - Testing Essentials

Node.js Handbook - Testing Essentials | JavaScript for Line of Business Applications | Scoop.it

This post will explain the tools needed to overcome the challenges of testing with Node.js. Together, they form an essential testing suite that will cover almost any project. The setup isn’t the most complex or feature-rich, but you could say that’s on purpose. If that sounds counter-intuitive… read on.

  • A Testing Framework (Mocha, Vows, Intern)
  • An Assertion Library (Chai, Assert)
  • Stubs (Sinon)
  • Module Control (Mockery, Rewire)
No comment yet.
Scoop.it!

Post Series on Building a Test-Driven Grocery List Application

I decided to dedicate this series to building a test-driven application that would allow me to create a Grocery List. I figured it will be a small enough application to not get muddled down in large, complex requirements and several moving parts but still provide a real-life example of a CRUD-based application.

A Grocery List application is also something I have wanted to make for some time. We still, as a household, create a grocery list with pen and paper and take it in hand to the store. Nothing wrong with that, aside from the general user error of a)forgetting the list at home, and the user experience oversight of b) not being able to split up and cover parts of the list as a group. So, I thought it may be handy to have a web-based application that my family could add to, remove from and have available on the one thing we never leave the house without: attitudes. No. smartphones.

 

* Part I – Introduction
* Part II – Feature: Add Item
* Part III – Feature: Mark-Off Item
* Part IV – Feature: List-Item-Controller
* Part V – Feature: List-Controller Refactoring
* Part VI – Back to Passing
* Part VII – Remove Item
* Part VIII – Bug Fixing
* Part IX – Persistence
* Part X – It Lives!

No comment yet.
Scoop.it!

Testing your frontend JavaScript code using mocha, chai, and sinon

Testing your frontend JavaScript code using mocha, chai, and sinon | JavaScript for Line of Business Applications | Scoop.it

For the 4 past months, I've been working for Mozilla on some big project where such testing strategy was involved. While I wish we could use CasperJSin this perspective, Firefox wasn't supported at the time and we needed to ensure proper compatibility with its JavaScript engine. So we went with usingMocha, Chai and Sinon and they have proven to be a great workflow for us so far.

Mocha is a test framework while Chai is an expectation one. Let's say Mocha setups and describes test suites and Chai provides convenient helpers to perform all kinds of assertions against your JavaScript code.

No comment yet.
Scoop.it!

An AngularJS Test Pyramid

An AngularJS Test Pyramid | JavaScript for Line of Business Applications | Scoop.it

As a team with a strong taste for automated testing we focused from the beginning on how to test our Angular app. In this post we want to describe our different types of tests and how they form a Test Pyramid.

Level 4: Selenium Tests.
Level 3: E2E (Scenario) Tests.
Level 2: Directive Tests.
Level 1: Unit Tests.

For each kind of test, we will explain the following aspects:

* Purpose: What’s the idea behind this type of tests. When to use and what is being tested (the scope of the test). Principles how to write the test.
* Implementation: How does it look like in source code. Examples, technical issues.
* Our experience: Reflection about our specific experience. Some heuristic data.

Ehab Roufail's curator insight, October 7, 2013 12:29 PM

Very similar approach to what we are adopting and have adopted recently.

Scoop.it!

Unit Testing AngularJS Controller Using QUnit and Sinon

Unit Testing AngularJS Controller Using QUnit and Sinon | JavaScript for Line of Business Applications | Scoop.it

Angular JS is known for and is becoming increasingly popular due to its nature of testability. Angular’s in-the- box abstractions make any amount of code easily testable. Code written using Angular JS can be tested using any JavaScript unit testing framework out there, may it be QUnitJasmineMocha or some other library.


QUnit is a JavaScript unit testing framework developed by jQuery team. It is used in the projects like jQueryjQuery UIjQUery Mobile. QUnit is a very simple and generic framework that can be used to test any piece of JavaScript code. Unlike Jasmine, QUnit doesn’t have built-in support for creating spies. 

Sinon is a JavaScript library that makes the process of creating spies, mocks and stubs easier. It doesn’t depend on any other JavaScript library and easily integrates with any JavaScript unit test framework. Official site has a nice API documentation covering different features of the library. 

No comment yet.
Scoop.it!

An introduction to JavaScript Unit Testing with qUnit and Sinon.js

An introduction to JavaScript Unit Testing with qUnit and Sinon.js | JavaScript for Line of Business Applications | Scoop.it

If you are developing for the web – apps or websites, then it is almost impossible to escape JavaScript. At some point, you will write some client-side code and as the application grows and the requirements become more complex, your JavaScript code is bound to grow with it. Like with every other complex piece of code, we need to be confident that the code behaves as expected. It doesn’t matter if you decide to use TDD or not, what’s important is to test your code. You can do this manually, very tedious and error prone, or programmatically. The choice is yours!

JavaScript is a different beast on its own, especially if you, like me, are used to doing server-side programming and testing. So how does one start with client-side unit tests?

No comment yet.
Scoop.it!

Writing Unit Tests for Existing JavaScript

Writing Unit Tests for Existing JavaScript | JavaScript for Line of Business Applications | Scoop.it

Our unit tests are organized into suites. Each suite consists of a number of files, each of which tests a single AMD module. Most of the modules under test when I started down this path were pretty isolated – they didn’t have a ton of dependencies generally, and had very few runtime dependencies. They didn’t interact with other modules that much. Almost all of the existing unit test files loaded a module, executed its methods, and inspected the return value. No big deal.

Feature-related code – especially already-written feature-related code – is a different story. Views have templates. Models expect data. Models pass information to views, and views pass information to models. Some models need parents; others expect children. And pretty much everything depended on a global-ish message broker to pass information around.

No comment yet.
Scoop.it!

Don't Forget to Cover Your Client Side!

Don't Forget to Cover Your Client Side! | JavaScript for Line of Business Applications | Scoop.it

By making sure that your application is tested, you are able to reduce the amount of bugs you find in your code, increase the maintainability of your application, and design well structured code. 

Client side unit testing presents different challenges than server side testing. When dealing with client side code, you will find yourself struggling to separate application logic from DOM logic, as well as just structuring JavaScript code in general. Fortunately there are a lot of great client side testing libraries out there to help test your code, create metrics about the test coverage, as well as analyze the complexity of it.

No comment yet.
Scoop.it!

Testing & Tooling in EmberJS

Testing & Tooling in EmberJS | JavaScript for Line of Business Applications | Scoop.it

One of my favorite parts of Ember is how easy it is to test. The framework comes bundled with a system testing framework, and its object model makes unit testing a breeze. Combine all that with a great test runner that has CI integration, and you have a really awesome testing ecosystem for your new app.

This framework allows you to make high-level assertions regarding your applications’ state, mostly by querying and interacting with the DOM through JQuery in a black box fashion. Since the tests are pure JavaScript however, we also get direct access to our running application if needed for testing.

The framework comes bundles with a few simple helpers to do common operations such as clicking a button, filling in a text field, or querying for the presence of a certain DOM element. A typical system test using ember-testing might look like this...

No comment yet.
Scoop.it!

Testable & Tested Client-side Code

Testable & Tested Client-side Code | JavaScript for Line of Business Applications | Scoop.it

Testing (i.e. linting, unit tests, integration testing etc..) client-side code is not done as commonly as it should be. The reason it is so commonly not done, besides lack of know-how, is that it is presupposed that it will take time away from other more productive development tasks.

This fallacious notion is, of course, wrong. The repeatable successes in software engineering based on testable (i.e. modular, loosely coupled, small, simple units of code) and tested code has proven again and again to be a time-saver and part of creating maintainable and understandable code. At a minimum, if code is not unit tested it is only a matter of time before it is burnt down and re-written, or abandoned altogether because it becomes unmaintainable and incomprehensible.

In this article, I am going to defend and talk about testing client-side code. It is my intention that the information in this article will give those among us who do not test, the desire and some initial testing knowledge to test, along with the ability to defend its necessity from any agent that might deter testing.

No comment yet.
Scoop.it!

How To Unit Test An Angular App.

How To Unit Test An Angular App. | JavaScript for Line of Business Applications | Scoop.it

AngularJS has a great testing story - it’s all based on Dependency Injection, the Karma test runner was written by one of its core developers Vojta Jina and it ships with a variety of mocks like the $httpBackend for unit testing requests to remote services.

What I haven’t been able to find much of are examples showing how to take advantage of these features when testing an application that does more than just expose objects connected via a rest api.

Today we’re going to build a simple Tic-Tac-Toe game writing unit tests along the way.

No comment yet.