SlideShare ist ein Scribd-Unternehmen logo
1 von 54
JSpec
A JavaScript Testing Framework
About me
About me
Lena Herrmann

Ruby, Javascript, CouchDB
About me
Lena Herrmann

Ruby, Javascript, CouchDB

http://lenaherrmann.net
@kilaulena
Upstream Agile GmbH

  http://upstre.am/
Unit Testing
Crosscheck                                  JSSpec
                    RhinoUnit

                     Test.More           jsUnity
   jsUnitTest

                                J3Unit             QUnit
                JSUnit
                                      DOH
Test.Simple
                                                   Jasmine

         JSTest                     TestCase
                         JSNUnit
 screw-unit
                                   YUI Test
Crosscheck                                  JSSpec
                    RhinoUnit

                     Test.More           jsUnity
   jsUnitTest

                                J3Unit             QUnit
                JSUnit


                  JSpec
                                      DOH
Test.Simple
                                                   Jasmine

         JSTest                     TestCase
                         JSNUnit
 screw-unit
                                   YUI Test
@tjholowaychuk
What does it look like?
Installation
Download tar from
http://github.com/visionmedia/jspec/downloads
Download tar from
http://github.com/visionmedia/jspec/downloads


or
$ git clone git://github.com/visionmedia/jspec.git
$ sudo gem install jspec
$ sudo gem install jspec



$ jspec init --rails
Run
$ jspec run --rhino
$ jspec run --browsers ff,safari --server
Grammar
Assertions
Grammar
Assertions

'hello'.should.eql('hello')
'hello'.should.eql 'hello'
Grammar
Functions
Grammar
Functions

-{ throw 'foo' }.should.throw_error 'foo'
Matchers
be, eql, equal
Matchers
be, eql, equal

 true.should.be true
 2.should.eql 2
 2.should.eql '2'
 ['foo', 'bar'].should.eql ['foo', 'bar']
 ['foo', 'bar'].should.not.equal ['foo', 'bar']
Matchers
be_a, be_an
Matchers
be_a, be_an

['im', 'an', 'array'].should.be_an Array
'im a string'.should.be_a String
Matchers
have_length
Matchers
have_length

['cookies', 'ice cream'].length.should.eql 2
['cookies', 'ice cream'].should.have_length 2
Matchers
include
Matchers
include

 ['cookies', 'apples'].should.include 'apples'
 ['cookies', 'apples'].should.not.include 'bread'
Matchers
have_property
Matchers
have_property

{ name: 'lena' }.should.have_property 'name'
{ name: 'lena' }.should.have_property 'name', 'lena'
Matchers
jQuery
Matchers
jQuery

$('form#login .agree').should.not.be_clicked
Matchers
jQuery

$('form#login .agree').should.not.be_clicked
$('form').should.have_id 'login'
Matchers
jQuery

$('form#login .agree').should.not.be_clicked
$('form').should.have_id 'login'

have_tag, have_child, have_text, have_class,
be_visible, be_selected, have_alt ...........
Fixtures
fixtures/storyboard.html:
Stubbing

person.stub('age').and_return(22)
Mocking
mock_request()
Thank you!

Weitere ähnliche Inhalte

Ähnlich wie JSpec - A Javascript Unit Testing Framework

Don't Leave Windows Broken
Don't Leave Windows BrokenDon't Leave Windows Broken
Don't Leave Windows BrokenKen William
 
Security testing of YUI powered applications
Security testing of YUI powered applicationsSecurity testing of YUI powered applications
Security testing of YUI powered applicationsdimisec
 
JavaScript Testing VIA Selenium
JavaScript Testing VIA SeleniumJavaScript Testing VIA Selenium
JavaScript Testing VIA SeleniumAdam Christian
 
Continuous Integration for front-end JavaScript
Continuous Integration for front-end JavaScriptContinuous Integration for front-end JavaScript
Continuous Integration for front-end JavaScriptLars Thorup
 
Testing React Native with Jest
Testing React Native with JestTesting React Native with Jest
Testing React Native with JestMuhammad Rizsky
 
Test driven node.js
Test driven node.jsTest driven node.js
Test driven node.jsJay Harris
 
Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...
Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...
Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...Paul King
 
Introduction to Venus.js
Introduction to Venus.jsIntroduction to Venus.js
Introduction to Venus.jsSeth McLaughlin
 
Painless JavaScript Testing with Jest
Painless JavaScript Testing with JestPainless JavaScript Testing with Jest
Painless JavaScript Testing with JestMichał Pierzchała
 
Superfast Automated Web Testing with CasperJS & PhantomJS
Superfast Automated Web Testing with CasperJS & PhantomJS Superfast Automated Web Testing with CasperJS & PhantomJS
Superfast Automated Web Testing with CasperJS & PhantomJS Hervé Vũ Roussel
 
I know why your Java is slow
I know why your Java is slowI know why your Java is slow
I know why your Java is slowaragozin
 
Jbehave- Basics to Advance
Jbehave- Basics to AdvanceJbehave- Basics to Advance
Jbehave- Basics to AdvanceRavinder Singh
 

Ähnlich wie JSpec - A Javascript Unit Testing Framework (19)

Jasmine
JasmineJasmine
Jasmine
 
Testable JavaScript
Testable JavaScriptTestable JavaScript
Testable JavaScript
 
Unit testing with java
Unit testing with javaUnit testing with java
Unit testing with java
 
Don't Leave Windows Broken
Don't Leave Windows BrokenDon't Leave Windows Broken
Don't Leave Windows Broken
 
Security testing of YUI powered applications
Security testing of YUI powered applicationsSecurity testing of YUI powered applications
Security testing of YUI powered applications
 
JavaScript Testing VIA Selenium
JavaScript Testing VIA SeleniumJavaScript Testing VIA Selenium
JavaScript Testing VIA Selenium
 
Continuous Integration for front-end JavaScript
Continuous Integration for front-end JavaScriptContinuous Integration for front-end JavaScript
Continuous Integration for front-end JavaScript
 
Testing React Native with Jest
Testing React Native with JestTesting React Native with Jest
Testing React Native with Jest
 
Test driven node.js
Test driven node.jsTest driven node.js
Test driven node.js
 
Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...
Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...
Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...
 
Javascript Unit Testing
Javascript Unit TestingJavascript Unit Testing
Javascript Unit Testing
 
Thomas Fuchs Presentation
Thomas Fuchs PresentationThomas Fuchs Presentation
Thomas Fuchs Presentation
 
Test Continuous
Test ContinuousTest Continuous
Test Continuous
 
Introduction to Venus.js
Introduction to Venus.jsIntroduction to Venus.js
Introduction to Venus.js
 
Painless JavaScript Testing with Jest
Painless JavaScript Testing with JestPainless JavaScript Testing with Jest
Painless JavaScript Testing with Jest
 
Superfast Automated Web Testing with CasperJS & PhantomJS
Superfast Automated Web Testing with CasperJS & PhantomJS Superfast Automated Web Testing with CasperJS & PhantomJS
Superfast Automated Web Testing with CasperJS & PhantomJS
 
I know why your Java is slow
I know why your Java is slowI know why your Java is slow
I know why your Java is slow
 
Jbehave- Basics to Advance
Jbehave- Basics to AdvanceJbehave- Basics to Advance
Jbehave- Basics to Advance
 
Seam Glassfish Perspective
Seam Glassfish PerspectiveSeam Glassfish Perspective
Seam Glassfish Perspective
 

Kürzlich hochgeladen

Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
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.pdfsudhanshuwaghmare1
 

Kürzlich hochgeladen (20)

Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
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
 

JSpec - A Javascript Unit Testing Framework

Hinweis der Redaktion

  1. We take TDD very seriously Working on my thesis there:
  2. My thesis: an outliner, a couchapp Have a project in mind where Javascript is the main language Application is served by CouchDB - no other server, other language involved
  3. Not about full stack integration test
  4. Tiny (15 kb compressed, 1600-ish LOC)
  5. project: 1 and a half years old, more than 30 forks on git in active development
  6. no parentheses, "function" expressions, curly brackets Cascading before/after hooks -- Nested describe blocks (DRY, organization) Textmate bundle, Syntax hightlighting
  7. grammar-less alternative
  8. Two ways to install jspec: 1st, when project should come without prerequisites
  9. Just drop the files into your project.
  10. 2nd: - when to be used with CI - when you DON'T want to test the DOM Rails command copies a jspec template folder into your project
  11. Two ways to run the tests
  12. Open the html file in any browser.
  13. Also show only failing tests
  14. Not so nice: instead of test groups, you have to put tests into different files
  15. Java implementation of Javascript (like Spidermonkey is in C)
  16. When you have the gem already installed: opens browsers in the background, report back to console
  17. equal = object identity ===
  18. there's many more
  19. there's many more
  20. there's many more
  21. sometimes you want to test DOM manipulation
  22. Mocking: - Possible to include Mocking frameworks - or as its JS, just override the methods