SlideShare a Scribd company logo
1 of 14
Download to read offline
jessie
TDD in node.js using Jasmine
Marcin Bunsch
nodecamp.eu 2011
Sunday, June 12, 2011
Jasmine
• JavaScript testing framework
• does not depend on any other JavaScript frameworks.
• does not require a DOM.
• does not pollute prototypes
• similar to RSpec
Sunday, June 12, 2011
describe('Simple specs', function() {
it("should work", function() {
expect("aaa").toEqual('aaa')
})
it("should work with not", function() {
expect("bbb").not.toEqual('aaa')
})
})
Jasmine - suites and specs
Sunday, June 12, 2011
expect(x).toEqual(y)
expect(x).toBe(y)
expect(x).toMatch(pattern)
expect(x).toBeDefined()
expect(x).toBeNull()
expect(x).toBeTruthy()
expect(x).toBeFalsy()
expect(x).toContain(y)
expect(x).toBeLessThan(y)
expect(x).toBeGreaterThan(y)
expect(fn).toThrow(e)
Jasmine - matchers
Sunday, June 12, 2011
describe('Before and after specs', function() {
var a = 1
beforeEach(function() { a += 1 })
afterEach(function() { a += 1 })
it("should execute the beforeEach", function() {
expect(a).toEqual(2)
})
it("should execute the afterEach", function() {
expect(a).toEqual(4)
})
})
Jasmine - before and after
Sunday, June 12, 2011
describe('Spies', function() {
var some_object = { some_func: function() {} }
it("should be able to spy on existing objects", function() {
spyOn(some_object, 'some_func')
some_object.some_func()
expect(some_object.some_func).toHaveBeenCalled()
})
it("should be able to create spies", function() {
var spy_func = jasmine.createSpy()
spy_func()
expect(spy_func).toHaveBeenCalled()
})
})
Jasmine - spies
Sunday, June 12, 2011
Jessie
• node.js runner for Jasmine
• extends Jasmine
• introduces pending specs
• improves error and failure reporting
• multiple report formatters
• supports CoffeeScript
Sunday, June 12, 2011
describe('Pending specs', function() {
it("should work")
it("should work with pending", function() {
pending("TODO")
})
})
Jessie - pending specs
Sunday, June 12, 2011
describe('Failing spec', function() {
it("should fail", function() {
expect(1).toEqual(2)
})
})
Jessie - failure reporting
Sunday, June 12, 2011
Jessie - formatters
Sunday, June 12, 2011
Jessie - formatters
Sunday, June 12, 2011
describe('Sugar specs', function() {
var number = 1
var array = [1,2]
var func = function() {}
it("should work", function() {
"aaa".should_be("aaa")
number.should_be(1)
array.should_be([1,2])
func.should_be_a(Function)
"bike courier".should_match("bike")
})
it("should work with not", function() {
"bbb".should_not_be("aaa")
number.should_not_be(2)
array.should_not_be([3,4])
})
})
Jessie - sugar
Sunday, June 12, 2011
describe 'OMG Coffee Spec', ->
it "should work", ->
expect(1).toEqual 1
it "should work", ->
"foo".should_be "foo"
Jessie - CoffeeScript
Sunday, June 12, 2011
github.com/futuresimple/jessie
Sunday, June 12, 2011

More Related Content

Similar to Jessie - TDD in node.js using Jasmine

Postgres vs Mongo / Олег Бартунов (Postgres Professional)
Postgres vs Mongo / Олег Бартунов (Postgres Professional)Postgres vs Mongo / Олег Бартунов (Postgres Professional)
Postgres vs Mongo / Олег Бартунов (Postgres Professional)Ontico
 
Javascript unit testing, yes we can e big
Javascript unit testing, yes we can   e bigJavascript unit testing, yes we can   e big
Javascript unit testing, yes we can e bigAndy Peterson
 
Joose - JavaScript Meta Object System
Joose - JavaScript Meta Object SystemJoose - JavaScript Meta Object System
Joose - JavaScript Meta Object Systemmalteubl
 
JS Lab`16. Сергей Селецкий: "Ретроспектива тестирования JavaScript"
JS Lab`16. Сергей Селецкий: "Ретроспектива тестирования JavaScript"JS Lab`16. Сергей Селецкий: "Ретроспектива тестирования JavaScript"
JS Lab`16. Сергей Селецкий: "Ретроспектива тестирования JavaScript"GeeksLab Odessa
 
How to unit test your React/Redux app
How to unit test your React/Redux appHow to unit test your React/Redux app
How to unit test your React/Redux appAlin Pandichi
 
JavaScript Unit Testing with an Angular 5.x Use Case 101
JavaScript Unit Testing with an Angular 5.x Use Case 101JavaScript Unit Testing with an Angular 5.x Use Case 101
JavaScript Unit Testing with an Angular 5.x Use Case 101Hazem Saleh
 
Terence Barr - jdk7+8 - 24mai2011
Terence Barr - jdk7+8 - 24mai2011Terence Barr - jdk7+8 - 24mai2011
Terence Barr - jdk7+8 - 24mai2011Agora Group
 
Clojure for Java developers - Stockholm
Clojure for Java developers - StockholmClojure for Java developers - Stockholm
Clojure for Java developers - StockholmJan Kronquist
 
Unit Testing your React / Redux app (@BucharestJS)
Unit Testing your React / Redux app (@BucharestJS)Unit Testing your React / Redux app (@BucharestJS)
Unit Testing your React / Redux app (@BucharestJS)Alin Pandichi
 
jrubykaigi2010-lt-rubeus
jrubykaigi2010-lt-rubeusjrubykaigi2010-lt-rubeus
jrubykaigi2010-lt-rubeusTakeshi AKIMA
 
Joose @jsconf
Joose @jsconfJoose @jsconf
Joose @jsconfmalteubl
 
Iasi code camp 12 october 2013 jax-rs-jee-ecosystem - catalin mihalache
Iasi code camp 12 october 2013   jax-rs-jee-ecosystem - catalin mihalacheIasi code camp 12 october 2013   jax-rs-jee-ecosystem - catalin mihalache
Iasi code camp 12 october 2013 jax-rs-jee-ecosystem - catalin mihalacheCodecamp Romania
 

Similar to Jessie - TDD in node.js using Jasmine (17)

jQuery-1-Ajax
jQuery-1-AjaxjQuery-1-Ajax
jQuery-1-Ajax
 
Postgres vs Mongo / Олег Бартунов (Postgres Professional)
Postgres vs Mongo / Олег Бартунов (Postgres Professional)Postgres vs Mongo / Олег Бартунов (Postgres Professional)
Postgres vs Mongo / Олег Бартунов (Postgres Professional)
 
Javascript unit testing, yes we can e big
Javascript unit testing, yes we can   e bigJavascript unit testing, yes we can   e big
Javascript unit testing, yes we can e big
 
Json generation
Json generationJson generation
Json generation
 
Joose - JavaScript Meta Object System
Joose - JavaScript Meta Object SystemJoose - JavaScript Meta Object System
Joose - JavaScript Meta Object System
 
JS Lab`16. Сергей Селецкий: "Ретроспектива тестирования JavaScript"
JS Lab`16. Сергей Селецкий: "Ретроспектива тестирования JavaScript"JS Lab`16. Сергей Селецкий: "Ретроспектива тестирования JavaScript"
JS Lab`16. Сергей Селецкий: "Ретроспектива тестирования JavaScript"
 
How to unit test your React/Redux app
How to unit test your React/Redux appHow to unit test your React/Redux app
How to unit test your React/Redux app
 
JavaScript Unit Testing with an Angular 5.x Use Case 101
JavaScript Unit Testing with an Angular 5.x Use Case 101JavaScript Unit Testing with an Angular 5.x Use Case 101
JavaScript Unit Testing with an Angular 5.x Use Case 101
 
Terence Barr - jdk7+8 - 24mai2011
Terence Barr - jdk7+8 - 24mai2011Terence Barr - jdk7+8 - 24mai2011
Terence Barr - jdk7+8 - 24mai2011
 
Clojure for Java developers - Stockholm
Clojure for Java developers - StockholmClojure for Java developers - Stockholm
Clojure for Java developers - Stockholm
 
Unit Testing your React / Redux app (@BucharestJS)
Unit Testing your React / Redux app (@BucharestJS)Unit Testing your React / Redux app (@BucharestJS)
Unit Testing your React / Redux app (@BucharestJS)
 
Basics of j query
Basics of j queryBasics of j query
Basics of j query
 
jrubykaigi2010-lt-rubeus
jrubykaigi2010-lt-rubeusjrubykaigi2010-lt-rubeus
jrubykaigi2010-lt-rubeus
 
10 jdbc
10 jdbc10 jdbc
10 jdbc
 
10 jdbc
10 jdbc10 jdbc
10 jdbc
 
Joose @jsconf
Joose @jsconfJoose @jsconf
Joose @jsconf
 
Iasi code camp 12 october 2013 jax-rs-jee-ecosystem - catalin mihalache
Iasi code camp 12 october 2013   jax-rs-jee-ecosystem - catalin mihalacheIasi code camp 12 october 2013   jax-rs-jee-ecosystem - catalin mihalache
Iasi code camp 12 october 2013 jax-rs-jee-ecosystem - catalin mihalache
 

Jessie - TDD in node.js using Jasmine