• Like

Loading…

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

Jessie - TDD in node.js using Jasmine

  • 8,653 views
Uploaded on

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

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.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
8,653
On Slideshare
0
From Embeds
0
Number of Embeds
1

Actions

Shares
Downloads
65
Comments
0
Likes
7

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. jessie TDD in node.js using Jasmine Marcin Bunsch nodecamp.eu 2011Sunday, June 12, 2011
  • 2. Jasmine • JavaScript testing framework • does not depend on any other JavaScript frameworks. • does not require a DOM. • does not pollute prototypes • similar to RSpecSunday, June 12, 2011
  • 3. Jasmine - suites and specs describe(Simple specs, function() { it("should work", function() { expect("aaa").toEqual(aaa) }) it("should work with not", function() { expect("bbb").not.toEqual(aaa) }) })Sunday, June 12, 2011
  • 4. Jasmine - matchers 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)Sunday, June 12, 2011
  • 5. Jasmine - before and after 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) }) })Sunday, June 12, 2011
  • 6. Jasmine - spies 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() }) })Sunday, June 12, 2011
  • 7. Jessie • node.js runner for Jasmine • extends Jasmine • introduces pending specs • improves error and failure reporting • multiple report formatters • supports CoffeeScriptSunday, June 12, 2011
  • 8. Jessie - pending specs describe(Pending specs, function() { it("should work") it("should work with pending", function() { pending("TODO") }) })Sunday, June 12, 2011
  • 9. Jessie - failure reporting describe(Failing spec, function() { it("should fail", function() { expect(1).toEqual(2) }) })Sunday, June 12, 2011
  • 10. Jessie - formattersSunday, June 12, 2011
  • 11. Jessie - formattersSunday, June 12, 2011
  • 12. Jessie - sugar 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]) }) })Sunday, June 12, 2011
  • 13. Jessie - CoffeeScript describe OMG Coffee Spec, -> it "should work", -> expect(1).toEqual 1 it "should work", -> "foo".should_be "foo"Sunday, June 12, 2011
  • 14. github.com/futuresimple/jessieSunday, June 12, 2011