testing meteorjs using casperjs

22
TESTING METEOR USING CASPER.JS A presentation by ( ) on Dec, 16th 2013. Stephan Hochhaus @yauh

Upload: stephan-hochhaus

Post on 28-Jan-2015

111 views

Category:

Technology


2 download

DESCRIPTION

A presentation on how to use Casper.js to test dynamic web applications build with Meteor.js. Original presentation created with reveal.js, find the code here: https://github.com/perlmonkey/caspermeetsmeteor

TRANSCRIPT

Page 1: Testing MeteorJS using CasperJS

TESTING METEOR USINGCASPER.JS

A presentation by ( ) on Dec, 16th 2013.Stephan Hochhaus @yauh

Page 2: Testing MeteorJS using CasperJS
Page 3: Testing MeteorJS using CasperJS

PUT YOUR APP TO THE TESTFunctional tests focus on user experience and ensure features

are working as expected (i.e. find bugs). Also they revealproblems with your requirements.

Page 4: Testing MeteorJS using CasperJS
Page 5: Testing MeteorJS using CasperJS

CHALLENGES IN TESTING DYNAMIC WEBAPPS

DOM is not ready on initial load

site elements are constantly changing

elements without proper IDs are hard to address and make

testing less robust

timing of steps is critical to successful testing

Page 6: Testing MeteorJS using CasperJS
Page 7: Testing MeteorJS using CasperJS

WHAT IS IT?Casper is both a testing & navigation frameworkIt is based on PhantomJSYou can easily create Jenkins Compatible JUnit XML

Page 8: Testing MeteorJS using CasperJS

CASPER CAN BE USED TO1. automate your browser to scrape stuff2. test sites and apps (which is what we're talking about here)

Page 9: Testing MeteorJS using CasperJS

(It just does, but that's not the topic of this presentation.)

Page 10: Testing MeteorJS using CasperJS
Page 11: Testing MeteorJS using CasperJS

HOW TO USE CASPERGrab PhantomJSGrab Casper version 1.1 (devel)Find a running Meteor appWrite some tests

Page 12: Testing MeteorJS using CasperJS

IF YOU ARE ON OS XINSTALL CASPERJS + PHANTOMJS USING HOMEBREW

$ brew install casperjs --devel

RUNNING A TEST$ casperjs test mytest.js

Page 13: Testing MeteorJS using CasperJS

REMEMBER THESE?In order to have a consistent basis for testing we'll make use of

some example apps provided by Meteor:

TodosParties

Page 14: Testing MeteorJS using CasperJS

CHEAT SHEETSSome ressources to help you understand

Infos about XPath

Page 15: Testing MeteorJS using CasperJS
Page 16: Testing MeteorJS using CasperJS

A CASPER SKELETONvar meteorUrl = 'http://localhost:3000/';

// Start your testingcasper.start(meteorUrl, function() { this.test.assertTitle('Todos', 'App title is as expected'); this.test.comment('Taking a picture to document our success'); this.capture('captures/a-website.png');

casper.then(function() { // do something else });

});

// don't forget to run your testscasper.run();

Page 17: Testing MeteorJS using CasperJS

LOOK AT OUR CAPTURE

Page 18: Testing MeteorJS using CasperJS

HANDS ONLET'S TEST THE EXAMPLES

Gentle introduction - Basic functionality - Logging in and setting up a party -

simpletest.jstodotest.js

partiestest.js

Page 19: Testing MeteorJS using CasperJS
Page 20: Testing MeteorJS using CasperJS

CONSIDER YOUR CHOICES 0.0.8

2.0.0-alpha24 2.4.0

0.3.1 1.15.1

Dalek.jsZombie.jsSeleniumLaikaMochaRTD - The Meteor Test Runner

Page 21: Testing MeteorJS using CasperJS
Page 22: Testing MeteorJS using CasperJS

THANK YOU!

I blog at , tweet as , and +1 as .

Feel free to .

yauh.de @yauh StephanHochhaus

fork this