Ghostbuster: Easier headless testing with PhantomJS (and CoffeeScript)
Ghostbuster from Joshua Hull from the Padrino team aims to make it even easier to get started with PhantomJS. Just by installing the gem, Ghostbuster will download and configure Phantom JS so you can write beautiful tests in CoffeeScript.
phantom.test.root = "http://127.0.0.1:4567" # you must specify your root.
phantom.test.add "Simple index", -> # this adds a test
@get '/', -> # this will get your a path relative to your root
@body.assertFirst 'p', (p) -> # this asserts the first paragraph's inner text
p.innerHTML == 'This is my paragraph' # is 'This is my paragraph'
@body.assertAll 'ul li', (li, idx) ->
li.innerHTML == "List item #{idx + 1}"
@succeed() # all tests must succeed
I love the simple test output. UTF-8 entities FTW:
GhostBuster
For /Users/joshbuddy/Development/ghostbuster/ghost/test_ghost.coffee
✓ Simple index
✓ Form input
✓ Link traversal
✗ Bad link traversal
Assert location failed: Excepted http://127.0.0.1:4567/not-correct, got http://127.0.0.1:4567/
✗ Form input not equal
Assert first for selector #out did not meet expectations
For /Users/joshbuddy/Development/ghostbuster/ghost/test_ghostmore.coffee
✓ Simple form
• Form should do more things
See the GitHub repo for usage.
Discussion
Sign in or Join to comment or subscribe