Skip to content

Instantly share code, notes, and snippets.

View jeffAwesome's full-sized avatar

Jeff Richardson jeffAwesome

View GitHub Profile

JavaScript Testing with Grunt, Mocha and Chai

In the following post I would like to introduce one way how you can setup your testing workflow for JavaScript development. The central components in the testing environment are Grunt, Mocha and Chai that I will cover from the introduction and installation of each component to the cooperation of all components for the execution of tests.

If you are already an experienced Grunt user and just look for the Gruntfile.js and the Mocha / Chai setup just skip the central components section and skip to the installing components part.

You can find the sample project with all code at GitHub on: https://github.com/maicki/sample-js-testing-grunt-mocha-chai

Central Components

Sublime Text 2 - Useful Shortcuts

Tested in Mac OS X: super == command

Open/Goto


  • super+t: go to file
  • super+ctrl+p: go to project
  • super+r: go to methods
@jeffAwesome
jeffAwesome / gist:4eb2007576f8432bcbd8
Created December 29, 2014 21:08
Balanced Send Payment to Bank Account
def send_payment
encounter = Encounter.find(self.encounter_id)
office = Admin.find(encounter.office_id)
bank_account = Balanced::BankAccount.fetch(office.bank_uri)
begin
credit = bank_account.credit(
:amount => self.amount.to_i * 100,
:description => 'Payment For '+encounter.title
)
set_paid_status
# this is the show.controller file
@Arc.module "MapApp.Show", (Show, App, Backbone, Marionette, $, _) ->
# the show controller method is public so we can access it
Show.Controller =
init: () ->
@getZones()
showMap: (map_view)->