Your SlideShare is downloading. ×
0
Automating JavaScript testing with Jasmine and Perl
Automating JavaScript testing with Jasmine and Perl
Automating JavaScript testing with Jasmine and Perl
Automating JavaScript testing with Jasmine and Perl
Automating JavaScript testing with Jasmine and Perl
Automating JavaScript testing with Jasmine and Perl
Automating JavaScript testing with Jasmine and Perl
Automating JavaScript testing with Jasmine and Perl
Automating JavaScript testing with Jasmine and Perl
Automating JavaScript testing with Jasmine and Perl
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Automating JavaScript testing with Jasmine and Perl

1,822

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,822
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
3
Comments
0
Likes
1
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
  • First 1..1 is subtest that enclose it()1..4 within subtest are actual expect() statements“ok 1” finalizes subtest results“ok 6” finalizes describe()
  • Transcript

    • 1. Automating JavaScript testing with Jasmine and Perl San Diego.pm talk Jun 21, 2012
    • 2. Testing JavaScript: Why• The usual unit testing benefits, but also:• Improving browser compatibility• Catching regressions in your code• Catching browser regressions – very important!
    • 3. Testing JavaScript: How• Many test frameworks out there, none of them as advanced and convenient as Test::Harness• All suffer from JavaScript restrictions on file system access, IO, etc.• Jasmine from Pivotal Labs is touted to be one of the best, which I think is true• But it’s also a pain to use: lots of boilerplate HTML just to run a spec, have to manage it all manually, etc.
    • 4. Solution: Test::WWW::Jasmine• Take Jasmine test specs, run them in Selenium controlled browser• Generate all the boilerplate HTML and JavaScript required to run the specs• Parse Jasmine output, convert it to TAP• Each describe() is a test, each expect() is a subtest• Test diagnostic printed out with diag(), native to TAP::Harness
    • 5. Example: Jasmine test spec/* * @css /css/css1.css * @script script1.js */describe(Test::WWW::Jasmine passing, function() { it(should run tests, function() { expect(true).toBeTruthy(); expect(false).toBeFalsy(); expect(undefined).toBeUndefined(); expect(null).toBeDefined() });});
    • 6. Example: test output1..6ok 1 - use Test::WWW::Jasmine;ok 2 - Got objectok 3 - Right object isa Test::WWW::Jasmineok 4 - Parsed all css scriptsok 5 - Parsed all js scripts 1..1 ok 1 - expectation 1 ok 2 - expectation 2 ok 3 - expectation 3 ok 4 - expectation 4 1..4 ok 1 - should run testsok 6 - jasmine multiple test
    • 7. Local testing• Automated testing is good, but it’d be cool if we could run the same specs locally while developing?• Enter jasmine.html: JavaScript/HTML spec runner that supports the same format as Test::WWW::Jasmine• Runs in browser locally, displays neat HTML (Jasmine default, actually)• Will be released soon, somewhere
    • 8. Local testing: how results look like
    • 9. Test::WWW::Jasmine warts• Work in progress, released to CPAN yesterday• Needs local (NFS anyone?) HTTP server with writable htdocs/something• Needs browser and Selenium installed• No headless testing yet (does it make sense?)• Maybe bundle jasmine.js along• Maybe run local tinyish HTTP server and serve specs off it
    • 10. Questions? Ideas?• http://metacpan.org/module/Test::WWW::Jas mine• http://github.com/nohuhu/Test-WWW- Jasmine• Drop me an e-mail: tokarev@cpan.org

    ×