SlideShare una empresa de Scribd logo
1 de 7
Descargar para leer sin conexión
Testowanie JavaScript

       Tomasz Bąk
    t.bak@selleo.com
Dlaczego JavaScript?


użytkownicy oczekują coraz większej

użyteczność interfejsów i szybkości

      JavaScript to zapewnia
Dlaczego Jasmine?
        dobrze integruje się z Rails
       składnia zbliżona do RSpec
   obsługa CoffeeScript / Asset Pipeline
matchery jQuery, fixturki widoków, Sinon.JS
        (test spies, stubs & mocks)
              tryb standalone
JavaScript || CoffeeScript
describe("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);
    });
  });
  ...
});
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");
         },
         ...
Demo

http://github.com/tb/testing-javascript
Dzięki


t.bak@selleo.com

Más contenido relacionado

La actualidad más candente

Google apps script database abstraction exposed version
Google apps script database abstraction   exposed versionGoogle apps script database abstraction   exposed version
Google apps script database abstraction exposed version
Bruce McPherson
 
Developing A Real World Logistic Application With Oracle Application - UKOUG ...
Developing A Real World Logistic Application With Oracle Application - UKOUG ...Developing A Real World Logistic Application With Oracle Application - UKOUG ...
Developing A Real World Logistic Application With Oracle Application - UKOUG ...
Roel Hartman
 

La actualidad más candente (20)

Do something in 5 with gas 4- Get your analytics profiles to a spreadsheet
Do something in 5 with gas 4- Get your analytics profiles to a spreadsheetDo something in 5 with gas 4- Get your analytics profiles to a spreadsheet
Do something in 5 with gas 4- Get your analytics profiles to a spreadsheet
 
React + Redux. Best practices
React + Redux.  Best practicesReact + Redux.  Best practices
React + Redux. Best practices
 
Tweaking the interactive grid
Tweaking the interactive gridTweaking the interactive grid
Tweaking the interactive grid
 
JavaScript client API for Google Apps Script API primer
JavaScript client API for Google Apps Script API primerJavaScript client API for Google Apps Script API primer
JavaScript client API for Google Apps Script API primer
 
Google apps script database abstraction exposed version
Google apps script database abstraction   exposed versionGoogle apps script database abstraction   exposed version
Google apps script database abstraction exposed version
 
React with Redux
React with ReduxReact with Redux
React with Redux
 
Creating sub zero dashboard plugin for apex with google
Creating sub zero dashboard plugin for apex with googleCreating sub zero dashboard plugin for apex with google
Creating sub zero dashboard plugin for apex with google
 
Do something in 5 with gas 3-simple invoicing app
Do something in 5 with gas 3-simple invoicing appDo something in 5 with gas 3-simple invoicing app
Do something in 5 with gas 3-simple invoicing app
 
Developing A Real World Logistic Application With Oracle Application - UKOUG ...
Developing A Real World Logistic Application With Oracle Application - UKOUG ...Developing A Real World Logistic Application With Oracle Application - UKOUG ...
Developing A Real World Logistic Application With Oracle Application - UKOUG ...
 
Object-Oriented Javascript
Object-Oriented JavascriptObject-Oriented Javascript
Object-Oriented Javascript
 
SPFx: Working with SharePoint Content
SPFx: Working with SharePoint ContentSPFx: Working with SharePoint Content
SPFx: Working with SharePoint Content
 
SPFx working with SharePoint data
SPFx working with SharePoint dataSPFx working with SharePoint data
SPFx working with SharePoint data
 
Rxjs marble-testing
Rxjs marble-testingRxjs marble-testing
Rxjs marble-testing
 
My Top 5 APEX JavaScript API's
My Top 5 APEX JavaScript API'sMy Top 5 APEX JavaScript API's
My Top 5 APEX JavaScript API's
 
SF Scala meet up, lighting talk: SPA -- Scala JDBC wrapper
SF Scala meet up, lighting talk: SPA -- Scala JDBC wrapperSF Scala meet up, lighting talk: SPA -- Scala JDBC wrapper
SF Scala meet up, lighting talk: SPA -- Scala JDBC wrapper
 
Redux with angular 2 - workshop 2016
Redux with angular 2 - workshop 2016Redux with angular 2 - workshop 2016
Redux with angular 2 - workshop 2016
 
React & Redux
React & ReduxReact & Redux
React & Redux
 
Redux training
Redux trainingRedux training
Redux training
 
Do something in 5 minutes with gas 1-use spreadsheet as database
Do something in 5 minutes with gas 1-use spreadsheet as databaseDo something in 5 minutes with gas 1-use spreadsheet as database
Do something in 5 minutes with gas 1-use spreadsheet as database
 
Do something in 5 with gas 7-email log
Do something in 5 with gas 7-email logDo something in 5 with gas 7-email log
Do something in 5 with gas 7-email log
 

Destacado

Birthday
BirthdayBirthday
Birthday
kikuya
 
Convegno Second Life - Seconda Parte
Convegno Second Life - Seconda ParteConvegno Second Life - Seconda Parte
Convegno Second Life - Seconda Parte
Philomène Gattuso
 
4cooks the back story
4cooks the back story4cooks the back story
4cooks the back story
belariava
 
Mcc Biology Unit 3 Course
Mcc Biology Unit 3 CourseMcc Biology Unit 3 Course
Mcc Biology Unit 3 Course
brendamenzel
 
Nile project
Nile projectNile project
Nile project
kikuya
 
Convegno Second Life - Terza parte
Convegno Second Life - Terza parteConvegno Second Life - Terza parte
Convegno Second Life - Terza parte
Philomène Gattuso
 
Vocabulary Body
Vocabulary  BodyVocabulary  Body
Vocabulary Body
kikuya
 

Destacado (17)

Birthday
BirthdayBirthday
Birthday
 
Replacing Rails asset pipeline with Gulp
Replacing Rails asset pipeline with GulpReplacing Rails asset pipeline with Gulp
Replacing Rails asset pipeline with Gulp
 
Convegno Second Life - Seconda Parte
Convegno Second Life - Seconda ParteConvegno Second Life - Seconda Parte
Convegno Second Life - Seconda Parte
 
Antacsal
AntacsalAntacsal
Antacsal
 
Festa dell’Architettura, Roma 11 giugno 2010 - La Torre di Asian
Festa dell’Architettura, Roma 11 giugno 2010  -  La Torre di AsianFesta dell’Architettura, Roma 11 giugno 2010  -  La Torre di Asian
Festa dell’Architettura, Roma 11 giugno 2010 - La Torre di Asian
 
Jak wnieść wkład w Open Source?
Jak wnieść wkład w Open Source?Jak wnieść wkład w Open Source?
Jak wnieść wkład w Open Source?
 
Functional Reactive Angular 2
Functional Reactive Angular 2 Functional Reactive Angular 2
Functional Reactive Angular 2
 
1018部落工作室
1018部落工作室1018部落工作室
1018部落工作室
 
Mantra
MantraMantra
Mantra
 
4cooks the back story
4cooks the back story4cooks the back story
4cooks the back story
 
Ldap novell
Ldap novellLdap novell
Ldap novell
 
Mcc Biology Unit 3 Course
Mcc Biology Unit 3 CourseMcc Biology Unit 3 Course
Mcc Biology Unit 3 Course
 
Ulepszanie aplikacji webowej z AngularJS
Ulepszanie aplikacji webowej z AngularJSUlepszanie aplikacji webowej z AngularJS
Ulepszanie aplikacji webowej z AngularJS
 
Nile project
Nile projectNile project
Nile project
 
Convegno su Second Life - Prima Parte
Convegno su Second Life - Prima ParteConvegno su Second Life - Prima Parte
Convegno su Second Life - Prima Parte
 
Convegno Second Life - Terza parte
Convegno Second Life - Terza parteConvegno Second Life - Terza parte
Convegno Second Life - Terza parte
 
Vocabulary Body
Vocabulary  BodyVocabulary  Body
Vocabulary Body
 

Similar a Testowanie JavaScript

exportDisabledUsersRemoveMailbox
exportDisabledUsersRemoveMailboxexportDisabledUsersRemoveMailbox
exportDisabledUsersRemoveMailbox
Daniel Gilhousen
 
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and JasmineSingle Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
Paulo Ragonha
 

Similar a Testowanie JavaScript (20)

Not your Grandma's XQuery
Not your Grandma's XQueryNot your Grandma's XQuery
Not your Grandma's XQuery
 
No More Promises! Let's RxJS!
No More Promises! Let's RxJS!No More Promises! Let's RxJS!
No More Promises! Let's RxJS!
 
Futures e abstração - QCon São Paulo 2015
Futures e abstração - QCon São Paulo 2015Futures e abstração - QCon São Paulo 2015
Futures e abstração - QCon São Paulo 2015
 
exportDisabledUsersRemoveMailbox
exportDisabledUsersRemoveMailboxexportDisabledUsersRemoveMailbox
exportDisabledUsersRemoveMailbox
 
Smarter Testing With Spock
Smarter Testing With SpockSmarter Testing With Spock
Smarter Testing With Spock
 
Hadoop Integration in Cassandra
Hadoop Integration in CassandraHadoop Integration in Cassandra
Hadoop Integration in Cassandra
 
XQuery Rocks
XQuery RocksXQuery Rocks
XQuery Rocks
 
RESTful API using scalaz (3)
RESTful API using scalaz (3)RESTful API using scalaz (3)
RESTful API using scalaz (3)
 
Expert JavaScript tricks of the masters
Expert JavaScript  tricks of the mastersExpert JavaScript  tricks of the masters
Expert JavaScript tricks of the masters
 
React table tutorial project setup, use table, and usefilter
React table tutorial project setup, use table, and usefilterReact table tutorial project setup, use table, and usefilter
React table tutorial project setup, use table, and usefilter
 
ES6 Overview
ES6 OverviewES6 Overview
ES6 Overview
 
Zend framework service
Zend framework serviceZend framework service
Zend framework service
 
Zend framework service
Zend framework serviceZend framework service
Zend framework service
 
Ruby on Rails testing with Rspec
Ruby on Rails testing with RspecRuby on Rails testing with Rspec
Ruby on Rails testing with Rspec
 
Stop Making Excuses and Start Testing Your JavaScript
Stop Making Excuses and Start Testing Your JavaScriptStop Making Excuses and Start Testing Your JavaScript
Stop Making Excuses and Start Testing Your JavaScript
 
Reactive Programming - ReactFoo 2020 - Aziz Khambati
Reactive Programming - ReactFoo 2020 - Aziz KhambatiReactive Programming - ReactFoo 2020 - Aziz Khambati
Reactive Programming - ReactFoo 2020 - Aziz Khambati
 
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and JasmineSingle Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
 
Functional UIs with Java 8 and Vaadin JavaOne2014
Functional UIs with Java 8 and Vaadin JavaOne2014Functional UIs with Java 8 and Vaadin JavaOne2014
Functional UIs with Java 8 and Vaadin JavaOne2014
 
Marble Testing RxJS streams
Marble Testing RxJS streamsMarble Testing RxJS streams
Marble Testing RxJS streams
 
JavaScript Fundamentals with Angular and Lodash
JavaScript Fundamentals with Angular and LodashJavaScript Fundamentals with Angular and Lodash
JavaScript Fundamentals with Angular and Lodash
 

Más de Tomasz Bak

Rails tobak2005
Rails tobak2005Rails tobak2005
Rails tobak2005
Tomasz Bak
 

Más de Tomasz Bak (13)

Design Patterns in React
Design Patterns in ReactDesign Patterns in React
Design Patterns in React
 
Building React CRUD app in minutes?
Building React CRUD app in minutes?Building React CRUD app in minutes?
Building React CRUD app in minutes?
 
How to migrate large project from Angular to React
How to migrate large project from Angular to ReactHow to migrate large project from Angular to React
How to migrate large project from Angular to React
 
JAMstack
JAMstackJAMstack
JAMstack
 
e2e testing with cypress
e2e testing with cypresse2e testing with cypress
e2e testing with cypress
 
How to GraphQL: React Apollo
How to GraphQL: React ApolloHow to GraphQL: React Apollo
How to GraphQL: React Apollo
 
How to GraphQL
How to GraphQLHow to GraphQL
How to GraphQL
 
Working with npm packages
Working with npm packagesWorking with npm packages
Working with npm packages
 
How to replace rails asset pipeline with webpack?
How to replace rails asset pipeline with webpack?How to replace rails asset pipeline with webpack?
How to replace rails asset pipeline with webpack?
 
JavaScript Promises
JavaScript PromisesJavaScript Promises
JavaScript Promises
 
Bardziej produktywny gmail
Bardziej produktywny gmailBardziej produktywny gmail
Bardziej produktywny gmail
 
Kerberos
KerberosKerberos
Kerberos
 
Rails tobak2005
Rails tobak2005Rails tobak2005
Rails tobak2005
 

Último

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Último (20)

Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 

Testowanie JavaScript

  • 1. Testowanie JavaScript Tomasz Bąk t.bak@selleo.com
  • 2. Dlaczego JavaScript? użytkownicy oczekują coraz większej użyteczność interfejsów i szybkości JavaScript to zapewnia
  • 3. Dlaczego Jasmine? dobrze integruje się z Rails składnia zbliżona do RSpec obsługa CoffeeScript / Asset Pipeline matchery jQuery, fixturki widoków, Sinon.JS (test spies, stubs & mocks) tryb standalone
  • 4. JavaScript || CoffeeScript describe("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. 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"); }, ...