Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Testowanie JavaScript

653 views

Published on

Hackfest #3 Bielsko-Biała

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Testowanie JavaScript

  1. 1. Testowanie JavaScript Tomasz Bąk t.bak@selleo.com
  2. 2. Dlaczego JavaScript?użytkownicy oczekują coraz większejużyteczność interfejsów i szybkości JavaScript to zapewnia
  3. 3. Dlaczego Jasmine? dobrze integruje się z Rails składnia zbliżona do RSpec obsługa CoffeeScript / Asset Pipelinematchery jQuery, fixturki widoków, Sinon.JS (test spies, stubs & mocks) tryb standalone
  4. 4. JavaScript || CoffeeScriptdescribe("Calculator", function() { describe "Calculator", -> describe("#add", function() { return it("adds two numbers", function() { describe "#add", -> var calculator; calculator = new Calculator(); it "adds two numbers", -> return expect(calculator.add(1, 1)).toEqual(2); calculator = new Calculator() }); expect(calculator.add(1, 1)).toEqual 2 }); describe("#subtract", function() { describe "#subtract", -> return it("subtracts two numbers", function() { var calculator; it "subtracts two numbers", -> calculator = new Calculator(); calculator = new Calculator() return expect(calculator.subtract(10, expect(calculator.subtract(10, 1)).toEqual 9 1)).toEqual(9); }); }); ...});
  5. 5. Matchery expect($(<div class="some-class"></div>)).toHaveClass("some-class")expect($(<div class="some-class"></div>)).not.toHaveClass("some-class") expect($(<div>some text</div>)).toHaveText(some text) expect($form).toHandle("submit") … beforeEach(function() { this.addMatchers({ toBeACalendar: function() { return this.actual.hasClass("hasDatepicker"); }, ...
  6. 6. Demohttp://github.com/tb/testing-javascript
  7. 7. Dziękit.bak@selleo.com

×