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.
• d...
describe('Simple specs', function() {
it("should work", function() {
expect("aaa").toEqual('aaa')
})
it("should work with ...
expect(x).toEqual(y)
expect(x).toBe(y)
expect(x).toMatch(pattern)
expect(x).toBeDefined()
expect(x).toBeNull()
expect(x).t...
describe('Before and after specs', function() {
var a = 1
beforeEach(function() { a += 1 })
afterEach(function() { a += 1 ...
describe('Spies', function() {
var some_object = { some_func: function() {} }
it("should be able to spy on existing object...
Jessie
• node.js runner for Jasmine
• extends Jasmine
• introduces pending specs
• improves error and failure reporting
• ...
describe('Pending specs', function() {
it("should work")
it("should work with pending", function() {
pending("TODO")
})
})...
describe('Failing spec', function() {
it("should fail", function() {
expect(1).toEqual(2)
})
})
Jessie - failure reporting...
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(...
describe 'OMG Coffee Spec', ->
it "should work", ->
expect(1).toEqual 1
it "should work", ->
"foo".should_be "foo"
Jessie ...
github.com/futuresimple/jessie
Sunday, June 12, 2011
Upcoming SlideShare
Loading in...5
×

Jessie - TDD in node.js using Jasmine

8,824

Published on

Jessie is a node.js runner for Jasmine BDD framework.

It allows running of Jasmine specs in node.js environment, adds pending specs, improves error and failure reporting.

0 Comments
7 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
8,824
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
67
Comments
0
Likes
7
Embeds 0
No embeds

No notes for slide

Jessie - TDD in node.js using Jasmine

  1. 1. jessie TDD in node.js using Jasmine Marcin Bunsch nodecamp.eu 2011 Sunday, June 12, 2011
  2. 2. 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
  3. 3. 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
  4. 4. 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
  5. 5. 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
  6. 6. 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
  7. 7. 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
  8. 8. describe('Pending specs', function() { it("should work") it("should work with pending", function() { pending("TODO") }) }) Jessie - pending specs Sunday, June 12, 2011
  9. 9. describe('Failing spec', function() { it("should fail", function() { expect(1).toEqual(2) }) }) Jessie - failure reporting Sunday, June 12, 2011
  10. 10. Jessie - formatters Sunday, June 12, 2011
  11. 11. Jessie - formatters Sunday, June 12, 2011
  12. 12. 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
  13. 13. describe 'OMG Coffee Spec', -> it "should work", -> expect(1).toEqual 1 it "should work", -> "foo".should_be "foo" Jessie - CoffeeScript Sunday, June 12, 2011
  14. 14. github.com/futuresimple/jessie Sunday, June 12, 2011
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×