Development on Va...
Follow
Find tag "QUnit"
9.6K views | +0 today
Development on Various Platforms
Your new post is loading...
Your new post is loading...
Rescooped by Ertunç Efeoğlu from JavaScript for Line of Business Applications
Scoop.it!

Buster.JS - A Browser and NodeJS JavaScript testing toolkit.

Buster.JS - A Browser and NodeJS JavaScript testing toolkit. | Development on Various Platforms | Scoop.it

Buster.JS is a JavaScript test framework for node and browsers.

It does browser testing with browser automation (think JsTestDriver), QUnit style static HTML page testing, testing in headless browsers (PhantomJS, jsdom), and more. Write your test case with Buster.JS and run it both in Node.js and in a real browser.

There’s a public API for almost everything. You can write reporters for customizing the output of buster test (we already have xUnit XML, traditional dots, specification, tap, TeamCity and more), write extensions that wrap other testing frameworks (we already have buster-jstestdriver), add your own testing syntax (we ship with xUnit and BDD), and much more. Again, the overview lists many of these things.

 


Via Jan Hesse
more...
No comment yet.
Rescooped by Ertunç Efeoğlu from JavaScript for Line of Business Applications
Scoop.it!

Introducing BrowserSwarm – Spend less time testing your next JavaScript project

Introducing BrowserSwarm – Spend less time testing your next JavaScript project | Development on Various Platforms | Scoop.it

An open source tool that helps Web developers automate testing of their JavaScript frameworks and libraries across devices and browsers. Quality frameworks are the foundation for the modern Web, but framework developers often do not have the resources to test across browsers. BrowserSwarm helps developers build great, interoperable frameworks. The project complements modern.IE, which provides a set of free tools and resources to help developers build Web sites for all modern browsers.

BrowserSwarm connects directly to your team’s code repository on GitHub and uses Sauce Labs’ cloud to automatically run Unit Tests using QUnit. A simple report separates which test cases passed and failed so you can quickly see what needs to be fixed.

BrowserSwarm provides test results using top frameworks and libraries such as prototype.js and Modernizr. You receive an overall pass rate across browsers and devices, along with individual test pass rates for top browsers.

 


Via Jan Hesse
more...
No comment yet.
Rescooped by Ertunç Efeoğlu from JavaScript for Line of Business Applications
Scoop.it!

How To Build a Testing Framework — Introduction To JavaScript Unit Testing

How To Build a Testing Framework — Introduction To JavaScript Unit Testing | Development on Various Platforms | Scoop.it

You probably know that testing is good, but the first hurdle to overcome when trying to write unit tests for client-side code is the lack of any actual units; JavaScript code is written for each page of a website or each module of an application and is closely intermixed with back-end logic and related HTML. In the worst case, the code is completely mixed with HTML, as inline events handlers.

What is a unit anyway? In the best case, it is a pure function that you can deal with in some way — a function that always gives you the same result for a given input. This makes unit testing pretty easy, but most of the time you need to deal with side effects, which here means DOM manipulations. It’s still useful to figure out which units we can structure our code into and to build unit tests accordingly.


Via Jan Hesse
more...
No comment yet.
Rescooped by Ertunç Efeoğlu from JavaScript for Line of Business Applications
Scoop.it!

Unit Testing AngularJS Controller Using QUnit and Sinon

Unit Testing AngularJS Controller Using QUnit and Sinon | Development on Various Platforms | 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 QUnit, Jasmine, Mocha or some other library.


QUnit is a JavaScript unit testing framework developed by jQuery team. It is used in the projects like jQuery, jQuery UI, jQUery 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. 


Via Jan Hesse
more...
No comment yet.
Rescooped by Ertunç Efeoğlu from JavaScript for Line of Business Applications
Scoop.it!

Testable & Tested Client-side Code

Testable & Tested Client-side Code | Development on Various Platforms | 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.


Via Jan Hesse
more...
No comment yet.
Rescooped by Ertunç Efeoğlu from JavaScript for Line of Business Applications
Scoop.it!

Concurrently Testing JavaScript

Concurrently Testing JavaScript | Development on Various Platforms | Scoop.it

You’ve heard of nCrunch, right?  It’s a continuous integration plugin for Visual Studio that tracks changes to your code and then automatically builds and runs your unit tests in the background whilst you type.  Once the results are back it decorates every line of code with a red or green light to indicate whether the tests are passing or failing.

Where are you going with this?
Good question. nCrunch is fantastic…for .NET development. I do a fair bit of work in .NET but more and more I find myself working in JavaScript and desperately missing the constant feedback.

So how can we get something similar for our JavaScript tests? By using grunt of course!

GruntJS (which I’ve been playing around with recently) can be setup to run QUnit tests using the headless PhantomJS browser and to feedback the results.  In fact, this is all nicely packaged up in the grunt-contrib-qunit package for you, so it’s pretty simple to set up.


Via Jan Hesse
more...
No comment yet.
Rescooped by Ertunç Efeoğlu from JavaScript for Line of Business Applications
Scoop.it!

Testing synchronous and asynchronous JavaScript callbacks with QUnit

Testing synchronous and asynchronous JavaScript callbacks with QUnit | Development on Various Platforms | Scoop.it

QUnit is a JavaScript unit testing framework. It is used to test projects like jQuery,jQuery UI and jQuery Mobile. It has got strong roots in frontend JavaScript testing and includes some neat features to test DOM operations. That’s why we’re using it for frontend testing in this screencast. QUnit is perfectly capable of testing your node.jsprojects as well, though.

 

Synchronous callbacks

How do you test that a callback function gets called after you pass it to another function? You can pass an anonymous function containing an assertion as a callback. But then the problem is, even if this assertion never gets executed, the test won’t fail because all other assertions passed. In QUnit, you can tell a test how many assertions should succeed. This way the test will fail if some assertions don’t get executed.

 

Asynchronous callbacks

But what if a callback is only invoked some time later, after a result came in or after some time passed? The test will probably have finished unsuccessfully by then. QUnit allows tests to wait for asynchronous callbacks to be called.

The screencast contains examples of both, synchronous and asynchronous callbacks. Watch the screencast to learn more!


Via Jan Hesse
more...
No comment yet.
Rescooped by Ertunç Efeoğlu from JavaScript for Line of Business Applications
Scoop.it!

Incredibly convenient testing of front-end Javascript with Node.js

Incredibly convenient testing of front-end Javascript with Node.js | Development on Various Platforms | Scoop.it

You do have automated testing for your front-end Javascript application / library / framework don’t you? And tests work equally well at console, browsers and Travis aren’t they? And you run them in every possible browser on each release (or even push) right? If the answer is no, you might be doing it wrong. Let’s see if we can do something about it!

This article briefly describes a little piece of theory behind testing of standalone front-end projects, issues that you are likely to meet and the solution I came up with.

When it comes to testing, the first question is — which framework are we going to use? There are numerous articles on the Internet that describe pros and cons of those.

I personally prefer Jasmine and Mocha (coupled with CoffeeScript and Chai they feel so much like RSpec). But it’s only a matter of taste in fact. Their capabilities are more or less equal.

Let’s say we have a framework. Then we can manually create HTML file, include JS we want to test, open it in a browser and, well, test. It’s certainly a kind of automatic testing already but still so far away from something reasonable. And the first thing to think about is Continuous Integration. You can only run such tests manually and see the results with your eyes. No “on-commit runs”, no Travis integration. Sadness.



Via Jan Hesse
more...
No comment yet.