Hacking together a VCR for JavaScript

At SimpleReach we have a very large number of internal API endpoints and each one can bring back dozens of fields of data into our Ember.js application. In order to make integration tests we started with static fixtures, but very soon the sheer number of fields and endpoints become overwhelming.

I really wanted something like VCR for Rails, but alas, there is nothing in the front-end world that does that yet.

Chrome provided a great hack to use though. In the network developer tools you can right click and select “save as HAR with content”. This will save a recording of all network requests that have happened since you opened the tool. Voila, instant tape of all the network requests that have happened on a site.


Once you have the HAR saved, you need a way to serve the information up programatically. Sinon.js has a mock server that will respond with saved JS based on incoming requests. Setting it up looks something like this:

Now, as long as an object has been passed to “server.respondWith” the server will respond to that.

In order to make the HAR file play nice with Sinon, I forked an application called “Mockbuilder“. Mockbuilder allows you to add a HAR file to a folder and it will automatically convert it into something that plays nicely with Sinon. The fork allows you to specify a url for internal request overwrites and a location where the new mock file should go. That way you can have it send them immediately to the mock folder in your application.

Not only does this make writing JavaScript integration tests much easier, it is also a great way to make completely offline demos of your application. Simple click around, save the HAR file, and then with the new mocks in place, you can click around the same way and it will use the recordings instead of the actual requests. Perfect for sales teams who want to have a gurantee that things will work the way they expected.

Presentation below.

EmberConf Presentation: Using Ember to Make the Seemingly Impossible Easy

At this year’s EmberConf on the 25th of March I gave a presentation with Heyjin highlighting some examples of times where using Ember has made our jobs seem infinitely easier.

EmberConf was an amazing experience, the Ember community is full of genuine and welcoming people and I am so excited to see the great things that this community will build together.

Slides and video below.

Ember.js NYC presentation: Your front end is not your back end

Last month I gave a lightning talk at the Ember.js NYC meetup. The talk was about designing your API based on what it was going to be used for by the users instead of designing it based on what is in the database.  I think that this tactic can be really effective as it reduces the complexity of the front end code, which is where your users are and where you really want everything to revolve around their experience, not the intricacies of your data layer. With more and more complexity living in the front end through frameworks like Ember.js our design decisions need to be giving more weight to the front end than they used to.

Video and slides below:

 

Video:

Slides:

http://slid.es/andremalan/your-front-end-is-not-your-back-end/

http://slid.es/andremalan/your-front-end-is-not-your-back-end/embed

Your Personal Learning Environment – Presentation to JumpStart 2010

I just finished presenting a workshop on Personal Learning Environments to around 300 international students for UBC’s JumpStart international orientation. I think it went really well, but for anybody reading this that went to the lecture, don’t hesitate to comment below on how I could improve.

My story arc was as follows:

In order to create and effective personal learning environment you need to recursively go through the following process: Continue reading “Your Personal Learning Environment – Presentation to JumpStart 2010”

Educational Technology, the Users’s Perspective

Last week I spoke at ETUG 2010. My talk was entitled “Educational Technology, the Users’s Perspective”. In the talk I made a case for user-centered design and then explained the perspective of over 96% of the users of educational technology. Below is the video of my presentation (only starts about 1:50 into the video) and read on for a short summary.

http://blip.tv/play/AYHmsGQC
Continue reading “Educational Technology, the Users’s Perspective”

Personal Learning Network Presentations


My prize for best returning presentation

Over the last 6 months I have given two presentations on the ideas of Personal Learning Environments/Networks. The first one was in late August for UBC Jump Start,  a 2 week orientation program for students that I attended in my first year at UBC and that provided me with great friends and learning experiences. The second presentation was give at the 2010 UBC Student Leadership Conference, a conference that I have been heavily involved with over the past few years and this year was co-chaired by two good friends of mine, June Lam and Robert Winson. I had some technical difficulties with the first presentation, but the second one went really well, I even won the “best returning presenter” award for it.

Continue reading “Personal Learning Network Presentations”