testing meteorjs using casperjs
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/caspermeetsmeteorTRANSCRIPT
TESTING METEOR USINGCASPER.JS
A presentation by ( ) on Dec, 16th 2013.Stephan Hochhaus @yauh
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.
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
WHAT IS IT?Casper is both a testing & navigation frameworkIt is based on PhantomJSYou can easily create Jenkins Compatible JUnit XML
CASPER CAN BE USED TO1. automate your browser to scrape stuff2. test sites and apps (which is what we're talking about here)
(It just does, but that's not the topic of this presentation.)
HOW TO USE CASPERGrab PhantomJSGrab Casper version 1.1 (devel)Find a running Meteor appWrite some tests
IF YOU ARE ON OS XINSTALL CASPERJS + PHANTOMJS USING HOMEBREW
$ brew install casperjs --devel
RUNNING A TEST$ casperjs test mytest.js
REMEMBER THESE?In order to have a consistent basis for testing we'll make use of
some example apps provided by Meteor:
TodosParties
CHEAT SHEETSSome ressources to help you understand
Infos about XPath
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();
LOOK AT OUR CAPTURE
HANDS ONLET'S TEST THE EXAMPLES
Gentle introduction - Basic functionality - Logging in and setting up a party -
simpletest.jstodotest.js
partiestest.js
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
THANK YOU!
I blog at , tweet as , and +1 as .
Feel free to .
yauh.de @yauh StephanHochhaus
fork this