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: 'Jasmine'. Clear
Scoop.it!

A Case Study in JavaScript Code Improvement

A Case Study in JavaScript Code Improvement | JavaScript for Line of Business Applications | Scoop.it
Raymond Camden shares how a recent project led him to integrate some workflow tools that helped him improve the quality of his JavaScript code.
  • While writing the JavaScript, I ran into a few bits of code that felt repetitive and seemed ripe for optimization. I intentionally ignored those thoughts and focused on getting the code working. Premature optimization is frowned upon for a reason. Now that the code is released though, I think it makes sense to go back through and look for improvements to the code base.
  • Obviously – and probably more sensible before the optimization, would be the use of unit tests. As this relies upon a remote service, writing tests could be problematic, but even a test that assumes that remote service is running perfectly would be better than no tests. Plus, if I write these tests first, I can then look into code changes and feel secure that I’ve not broken anything.
  • I’m a big fan of JSHint and would like to run it over the code base and make sure it passes that test as well.
  • I’d also like to ship a minified version of the library. To be honest, I’ve never done that before, but if I had to guess, I’d bet there is a command line program I could run to generate that.
  • Finally, I bet I can handle running the unit tests, JSHint checking, and the minification, automatically via a tool like Grunt or Gulp.
No comment yet.
Scoop.it!

Unit Testing w/ AngularJS

Unit testing is all about isolation and dependency injection makes isolation a breeze. Seasoned Java developers have known this for years. The Spring framework, ubiquitous in Java backends today, introduced dependency injection (or at least popularized it) and brought a great number of benefits in terms of decoupling, modularity, flexibility and testability. Simply put, dependency injection lets you swap out real implementations for mock ones and it damn near forces you to decouple every component.

No comment yet.
Scoop.it!

introduction to unit test for AngularJS

introduction to unit test for AngularJS | JavaScript for Line of Business Applications | Scoop.it

Jasmine is like writing English. It is something easy to read and understand (which is waay cool). Jasmine spec files are normally wrapped on a describe block which receives a string to define what are we describing. They are used to group tests. We can see how we have another describe block which is nested in the previous one with the addition as parameter. See how are we grouping the tests?

No comment yet.
Scoop.it!

Stop Making Excuses and Start Testing Your JavaScript

Talk from HTML5DevConf about JavaScript unit testing.
No comment yet.
Scoop.it!

Jest | Painless JavaScript Unit Testing

Jest | Painless JavaScript Unit Testing | JavaScript for Line of Business Applications | Scoop.it

In order to write an effective unit test, you want to be able to isolate a unit of code and test only that unit – nothing else. It is fairly common and good practice to consider a module such a unit, and this is where Jest excels. Jest makes isolating a module from its dependencies extremely easy by automatically generating mocks for each of the module's depenedencies and providing those mocks (rather than the real dependency modules) by default.

Jan Hesse's insight:

http://www.infoq.com/news/2014/06/facebook-jest

No comment yet.
Scoop.it!

Testing Ember with Jasmine 2.0

Testing Ember with Jasmine 2.0 | JavaScript for Line of Business Applications | Scoop.it

Testing can be hard and Ember doesn't exactly have the greatest resources for testing. QUnit is the "official" testing framework for Ember.js apps and it has the most resources dedicated to it which can make using something like Jasmine a bit harder.

Ember requires a bit of setup to get working properly with Jasmine. Before anything else, we need to set up our helpers/spec_helper.js file. The following code sets Ember up for testing, gives us our test helpers, and even puts a small div showcasing our app in the bottom right corner...

No comment yet.
Scoop.it!

QUnit or Jasmine?

* Jasmine - a BDD framework that's clearly influenced by RSpec, and

* QUnit - a more traditional test framework from the jQuery project.

 

I compared them on three criteria:

1. Speed of setup. I tend to avoid testing tools that take me more than hour to get up and running.

2. Simplicity. Test frameworks don't need to be complicated; they just need to let me specify how my code should behave and keep out of my way. All things being equal, I'll choose an xUnit style testing framework to an RSpec style framework. If you're thinking "but I prefer BDD!" don't forget that the "B" in BDD is just language, and you can use that language in any framework you like.

3. Support for Continuous Integration. If you can't run your test suite automatically then sooner or later you'll forget to run it manually, and at some point ship a broken app to your users. Running tests in your CI build also enables you to automate continuous deployment, which is always a giggle.

No comment yet.
Scoop.it!

Walkthrough: Killing Bugs in AngularJS with Karma & Jasmine

Walkthrough: Killing Bugs in AngularJS with Karma & Jasmine | JavaScript for Line of Business Applications | Scoop.it
Follow along in this two part series as we walk through the steps to test for bugs in AngularJS.

First, we will write unit tests that reflect the intended behavior and then fix the bug so these tests pass. The goal is to improve code maintainability and reduce regression bugs.Download or clone the repo to follow along – each step has a corresponding branch to checkout.

We are going to focus on the play/pause functionality of the player. By right-clicking on the video element, we can see that the video will play and pause.

We will write tests for both the controller and the directive for this button in order to make sure our tests are small, consistent and maintainable.

No comment yet.
Scoop.it!

How to Unit Test Controllers In AngularJS Without Setting Your Hair On Fire

How to Unit Test Controllers In AngularJS Without Setting Your Hair On Fire | JavaScript for Line of Business Applications | Scoop.it
Developers almost universally agree that unit tests are a VERY GOOD THING when working on a project. They help you feel like your code is airtight, ensure reliability in production, and let you refactor with confidence when there is a need to do so.

AngularJS code touts its high degree of testability, which is a reasonable claim. In much of the documentation end to end tests are provided with the examples. Like so many things with Angular, however, I was finding that although unit testing was simple, it was not easy. Examples were sparse and though the official documentation provided some snippets of examples, putting it all together in my “real-world” case was proving challenging. So here I’ve written a little bit about how I ended up getting that wonderful green light for a passing build to show up.

* Instant Karma

* Writing Tests With Jasmine

* $httpBackend Is Cool

* Conclusion

No comment yet.
Scoop.it!

Spy on JavaScript Methods Using the Jasmine Testing Framework

One of the primary aims of unit testing is to isolate a method or component that you want to test and see how it behaves under a variety of circumstances. These might include calls with various arguments - or even none at all, - or whether it calls other methods as it should. Unfortunately, many methods and/or objects have dependencies on other methods and/or objects, such as network connections, data sources, files, and even previously executed methods. This is where mocks come in. A mock is a fake object that poses as the real McCoy in order to satisfy the inherent dependency(ies) without having to go through the overhead of creating the real object.

Mocks work by implementing the proxy pattern. When you create a mock object, it creates a proxy object that takes the place of the real object. We can then define what methods are called and their returned values from within our test method. Mocks can then be utilized to retrieve run-time statistics on the spied function.

No comment yet.
Scoop.it!

AngularJs Good Unit Test Structure For Controllers & How to test ajax code and Promises

AngularJs Good Unit Test Structure For Controllers & How to test ajax code and Promises | JavaScript for Line of Business Applications | Scoop.it

The poorly the structure is made for unit testing the more and more complected it will take to write a unit test for a simple functioning piece of code , and it will feel that your fighting your way against testing, instead it should feel more fun! So i’ll be showing a structure that worked for me very well when working with angular controllers Before going deep with the structure, i’ll be using

* Jasmine (unit testing)

* Jasmine spies (mocking)

* karma (because its awesome)

No comment yet.
Scoop.it!

Advanced Testing and Debugging in AngularJS

Advanced Testing and Debugging in AngularJS | JavaScript for Line of Business Applications | Scoop.it
Learn to test, debug and prepare the test code on your AngularJS application like a Pro using Jasmine unit testing and Protractor integration testing

AngularJS is becoming immensely popular and mainstream which means that there is a lot of AngularJS code out there that is being tested or is yet to be tested. And now that you're well on your way to test like a pro, thanks to the abundance of articles, tutorials, books and material out there on AngularJS testing & development, testing should be a mandatory process of your web development workflow.

Full-Spectrum testing with AngularJS & Karma taught us how to test certain areas of your AngularJS application, but how do we test efficiently? How do we debug a problem down the root cause? How do we skip tests, set breakpoints, and professionally mock-out our test components so that we can catch hidden bugs and unexpected scenarios? How far can and should we go with Unit & E2E testing? What else should we consider. Well lets take adeeper dive into testing in AngularJS and expand our minds by learning how to become a professional front-end tester.

Table of Contents:
* Presentation Slides + Video
* What to test and what not to test
* Preparing your test environment with Karma & Grunt
* Write tests as you go
* So when do you do your testing?
* Module & Inject Breakdown
* Powerful Mocking Strategies
* Sync' and Async' testing
* Skipping and Filtering tests
* Echoing data back to screen
* Using Breakpoints
* Writing Efficient Tests
* Testing older browsers
* Invest into preparing a CI environment
* Feedback Please!

No comment yet.
Scoop.it!

Creating and testing Meteor applications with BDD using Velocity and Jasmine

Creating and testing Meteor applications with BDD using Velocity and Jasmine | JavaScript for Line of Business Applications | Scoop.it
In this tutorial, I would like to present how to safely develop Meteor application using Behaviour Driven Development (BDD), using the new Velocity framework and Jasmine test suite. This tutorial a...
No comment yet.
Scoop.it!

REST API Testing—Frisby.js

REST API Testing—Frisby.js | JavaScript for Line of Business Applications | Scoop.it

Frisby is a REST API testing framework built on node.js and Jasmine that makes testing API endpoints easy, fast, and fun. 

Inspector helpers are useful for viewing details about the HTTP response when the test does not pass, or has trouble for some reason. They are also useful for debugging the API itself as a more user-friendly alternative to curl.

No comment yet.
Scoop.it!

Building robust web apps with React: in-browser prototypes, optimising with Browserify, testing with Jasmine

Building robust web apps with React: in-browser prototypes, optimising with Browserify, testing with Jasmine | JavaScript for Line of Business Applications | Scoop.it
The robustness engrained into key parts of the web stack gets forgotten as we build more dynamic applications, users might not get anything when even a small problem occurs. React provides a straightforward means to creating adaptive-hybrid or isomorphic web applications which can inject robustness back into our projects.



  • in-browser prototypes
  • optimising with Browserify
  • testing with Jasmine
Jan Hesse's insight:

http://maketea.co.uk/2014/03/05/building-robust-web-apps-with-react-part-1.html

http://maketea.co.uk/2014/04/07/building-robust-web-apps-with-react-part-2.html

http://maketea.co.uk/2014/05/22/building-robust-web-apps-with-react-part-3.html

No comment yet.
Scoop.it!

Jest + jQuery for testing a vanilla “app”

Jest + jQuery for testing a vanilla “app” | JavaScript for Line of Business Applications | Scoop.it

Jest is a new javascript testing tool announced today. I thought I'd take it out for a spin testing the UI of a simple vanilla JS app - no CommonJS modules, no fancy stuff. Just old school JavaScript. Granted, it's probably not what the tool was optimized to do, but it totally worked.

The thing about Jest is that it mocks everything. Which is priceless for unit testing. But it also means you need to declare when you don't want something mocked. 

No comment yet.
Scoop.it!

Which JavaScript Test Library Should You Use? QUnit vs Jasmine vs Mocha

Which JavaScript Test Library Should You Use? QUnit vs Jasmine vs Mocha | JavaScript for Line of Business Applications | Scoop.it

Whether you’re writing javaScript for the browser or for nodeJS, the question exists: what unit test library should I use to ensure my javascript code is working as expected?  There are plenty to choose from, and several that are popular.  If you were considering jUnit, Jasmine, or Mocha, then I’ve got some information you might be interested in: the good, the bad, and the ugly.

Arik Grinstein's curator insight, May 16, 2014 9:29 AM

Testing the Tests

Scoop.it!

Ember.js testing with Jasmine

Before diving right into the Jasmine Ember.Test.Adapter I wrote, let's take a quick look at the differences with Async control using Qunit vs. Jasmine - see Asynchronous Support, along with Ember's primary async control method used in its integration test helper suite.

This adapter is just one implementation, but I haven't seen another out there yet. There's still some work to be done (see TODOs), so please feel free to share any comments, questions, etc. -- as always, contributions welcome.

Hopefully this at least helps remove some of the burden of using Jasmine testing in your Ember apps. Salud.


No comment yet.
Scoop.it!

Testing AngularJS directive templates with Jasmine and Karma

Testing AngularJS directive templates with Jasmine and Karma | JavaScript for Line of Business Applications | Scoop.it

In my day job, I work on appear.in, a video chat service built with AngularJS and WebRTC. Recently, our application has become more complex, and our HTML templates ended up having a lot of state in them. We could no longer just use unit testing to verify our application logic, we also needed to test the state in our templates.

For our unit testing, we landed on using Jasmine and Karma, and this has worked fairly well for us. So when we wanted to test our templates, we wanted to use the same tools.

No comment yet.
Scoop.it!

Unit and End to End Testing in AngularJS

Unit and End to End Testing in AngularJS | JavaScript for Line of Business Applications | Scoop.it

Unit testing is a technique that helps developers validate isolated pieces of code. End to end testing (E2E) comes into play when you want to ascertain that a set of components, when integrated together, work as expected. AngularJS, being a modern JavaScript MVC framework, offers full support for unit tests and E2E tests. Writing tests while developing Angular apps can save you great deal of time which you would have otherwise wasted fixing unexpected bugs. This tutorial will explain how to incorporate unit tests and E2E tests in an Angular application. The tutorial assumes that you are familiar with AngularJS development. You should also be comfortable with different components that make up an Angular application.

We will use Jasmine as the testing framework and Karma as the test runner. You can use Yeoman to easily scaffold a project for you, or just quickly grab the angular seed app from GitHub.

No comment yet.
Scoop.it!

Angular/Jasmine Testing

Angular/Jasmine Testing | JavaScript for Line of Business Applications | Scoop.it

16) Angular/Jasmie, ngModelController and $parsers
A special episode by viewer request. How do you test $parsers, $formatters or otherwise in your Angular directives?

15) Angular/Jasmine, Inherited Directive Testing
Episode 15 in our Angular/Jasmine unit testing series. Testing directives that directly inherit from their parent (either directive or controller).

14) Angular/Jasmine, Inherited Controller Testing
Episode 14 in our series on Angular JS testing with Jasmine. Testing controllers that inherit $scope methods and properties from other controllers.

13) Angular/Jasmine, Testing Service Calls W/ Spies
Episode 13 in our Angular/Jasmine testing series. This episode shows how to setup service tests with spies.

12) Angular/Jasmine, Re-Tooling Configurations
Episode 12 of our Angular / Jasmine testing series. Re-tooling your Angular configuration for easier and more standardized testability.

11) Angular/Jasmine, Spying on Factories
Episode 11 in our Angular JS / Jasmine unit testing series. Using jasmine spies, specifically on Angular factories.

10) Angular/Jasmine, Testing Event Listeners
Episode 10 of our Angular JS Jasmine testing series. Testing event listeners in controllers and elsewhere. We welcome your feedback and requests.

9) Angular/Jasmine, Testing Watchers
Episode 9 of our Angular/Jasmine testing series. Testing scope watch methods in controllers and elsewhere. We are very thankful for your comments and requests.

8) Angular/Jasmine, Testing Directives W/ External Templates
Episode 8 in our Angular/Jasmine series. The configuration and testing approach for directives with external templates. Please leave feedback.

7) Angular/Jasmine, Directive Testing Part I
Episode 7 in our series on Angular/Jasmine testing. This is part I of testing directives. For more info on this, you should also check out: http://egghead.io/lessons/angularjs-unit-testin…

6) Angular/Jasmine, Filter Testing
Episode 6 in our Angular JS Jasmine unit testing series. This episode is about testing filters outside of the DOM.

5) Angular/Jasmine, Factory Testing
Episode 5 of our Angular Jasmine unit testing series. Testing factories and values.

3) Angular/Jasmine, Controller Testing
Episode 3 in our Angular Jasmine testing series. Testing controllers and methods on the $scope.

4) Angular/Jasmine, Controller Testing ('this' methods)
Episode 4 in our Angular Jasmine testing series. Testing instance methods on controllers, as supported by Angular 1.2.

2) Angular/Jasmine, Bower
Episode 2 in our Angular JS Jasmine unit testing series. Loading third party libraries with bower.

1) Angular/Jasmine, Setup
The first of our Angular Jasmine testing series. A video about how to setup your Angular testing environment.

No comment yet.
Scoop.it!

Code Coverage of Jasmine Tests using Istanbul and Karma

Code Coverage of Jasmine Tests using Istanbul and Karma | JavaScript for Line of Business Applications | Scoop.it

For modern web application development, having dozens of unit tests is not enough anymore. The actual code coverage of those tests would reveal if the application is thoroughly stressed or not. For tests written using the famous Jasmine test library, an easy way to have the coverage report is viaIstanbul and Karma.

Behind the scene, Karma is using Istanbul, a comprehensive JavaScript code coverage tool (read also my previous blog post on JavaScript Code Coverage with Istanbul). Istanbul parses the source file, in this example sqrt.js, using Esprima and then adds some extra instrumentation which will be used to gather the execution statistics.

No comment yet.
Scoop.it!

Step by Step Guide for Unit Testing ExtJS Application using Jasmine

Step by Step Guide for Unit Testing ExtJS Application using Jasmine | JavaScript for Line of Business Applications | Scoop.it

This article is a Step by Step guide on how to do Unit testing of ExtJS application using Jasmine Framework. The MVC approach of ExtJS along with the ‘Behavior Driven Testing’ approach of Jasmine Framework enables independent testing of ExtJS model, store and controller.

No comment yet.