Skip to content

Instantly share code, notes, and snippets.

@mikegrassotti
Created September 5, 2012 19:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikegrassotti/3642665 to your computer and use it in GitHub Desktop.
Save mikegrassotti/3642665 to your computer and use it in GitHub Desktop.
Testable emberjs apps

To run in your environment:

# clone gist and spin up a web server: 
git clone git://gist.github.com/3642665.git gist-3642665
cd gist-3642665
# npm install serve -g
serve -p 6001 &
open index.html
# Execute casperjs test to run tests and capture screenshots
casperjs test.coffee
# Review test output and screenshots
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Bootstrap, from Twitter</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.0.4/css/bootstrap-combined.min.css" rel="stylesheet">
</head>
<body>
<script src="http://code.jquery.com/jquery-1.8.1.js"></script>
<script src="http://code.jquery.com/ui/1.9.0-rc.1/jquery-ui.js"></script>
<script src="https://github.com/downloads/wycats/handlebars.js/handlebars-1.0.0.beta.6.js"></script>
<script src="https://github.com/downloads/emberjs/ember.js/ember-latest.js"></script>
<script src="https://github.com/downloads/emberjs/data/ember-data-latest.js"></script>
</body>
</html>
casper = require('casper').create()
casper.start 'http://127.0.0.1:6001', ->
@viewport 1024, 768
casper.then ->
@clickLabel 'Fade', 'a'
@test.assertTextExists 'Fade modal'
@capture 'fade.png'
@clickLabel 'Close fade', 'a'
casper.then ->
@clickLabel 'Hide', 'a'
@test.assertTextExists 'Hide modal'
@capture 'hide.png'
@clickLabel 'Close hide', 'a'
casper.run ->
@test.renderResults true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment