I'm pleased to present a re-write of the Backbone TodoMVC app using ECMAScript 6 features such as classes, modules and fat-arrow syntax. Developing Applications: Building Better JavaScript Applications [Addy Osmani] on *FREE* shipping on qualifying offers. If you want. Backbone Aura. Contribute to addyosmani/backbone-aura development by creating an account on GitHub.


Author: Marielle Waelchi
Country: New Zealand
Language: English
Genre: Education
Published: 10 July 2017
Pages: 788
PDF File Size: 22.48 Mb
ePub File Size: 27.31 Mb
ISBN: 557-4-11184-321-7
Downloads: 59205
Price: Free
Uploader: Marielle Waelchi


Developing Applications -

Comparing the actual output of a function against the expected output: The reason the test against "double" fails is because it was purposefully written incorrectly. Adding structure to assertions Housing all of our assertions in one test case can quickly become difficult to maintain, but luckily QUnit supports structuring blocks of addy osmani backbone more cleanly.

This can be done using module - a method that allows us to easily group tests together.


A typical approach to grouping might be keeping multiple tests testing a specific method as part of the same group module. Using setup and teardown: Using setup and teardown for instantiation and clean-up: A teardown addy osmani backbone is used to simply clear our a list of errors we might be storing within the window scope, but is otherwise not needed.

It passes if actual!

Unlike strictEqualit works on objects, arrays and primitives. Managing the clean-up of addy osmani backbone operations between tests can be a genuine pain, but thankfully QUnit has a solution to this problem in the form of the qunit-fixture element, seen below.

Let us addy osmani backbone go through a more complete example of using fixtures. You may have used jQuery plugins before that manipulated a given list in a particular way and it can be useful to test that the final manipulated output of the plugin is what was expected.

The code snippet for the plugin can be found below, followed by an example of the output is generates: First, we define the markup for a list containing some sample items inside our qunit-fixture element: No arguments passed - i.

Developing Backbone.js Applications

That said, what about tests that require asynchronous callbacks such as expensive processes, Ajax requests and so on? We know that our Ajax addy osmani backbone is asynchronous and so we first call stoprun the code making the request and finally at the very end of our callback, inform QUnit that it is okay to continue running other tests.

This improves readability when dealing with a mixture of asynchronous and synchronous tests in your suite. To factor this into our tests, we can use expect once again to define how many assertions we expect to see within our test. This is a healthy safety blanket as it ensures that if a test completes with an insufficient addy osmani backbone of assertions, we know something went wrong and fix it.


SinonJS Similar to the section on testing Backbone. Test spies are functions which record arguments, addy osmani backbone and return values for any of their calls.

In testing frameworks, spies can usually be either anonymous functions or wrap functions which already exist.


In order for us to substitute support for spies in QUnit, we will be taking advantage of a mocking framework called SinonJS by Christian Addy osmani backbone. Anonymous spies Spying on existing methods A rich inspection interface Using this.

This is comparable to jasmine. Each Todo instance will be rendered on the page by a TodoView: View addy osmani backbone is instantiated with an associated Model.

In our example, the render method uses addy osmani backbone template to construct the HTML for the Todo item which is placed inside an li element. Each call to render will replace the content of the li element using the current Model data.

- Traceur-TodoMVC - a app written with ES6

Thus, a View instance renders the content of a DOM element using the attributes of an associated Model. Later we will see how a View can addy osmani backbone its render method to Model change events, causing the View to re-render whenever the Model changes.

So far, we have seen that Backbone. View implements the View.

Related Post