![]() ![]() This might sound redundant – our tests are already going to be executed in the headless webkit environment, so why bother running them in the browser too? Well, the browser Jasmine runner tends to give a lot more information when something goes wrong – stack traces and most importantly a live debugger.įinally we add the terminal-notifier-guard gem, which just allows guard to give us a notification each time the tests finish executing. TERMINAL NOTIFIER GUARD FULLNext up we grab guard-livereload, which enables Guard to act as a livereload server, automatically running your full suite in the browser each time your save a file. Next we’re going to add the ‘jasmine-headless-webkit’ gem and its guard twin, which use phantomjs to run your tests on the command line, without needing a browser window. First we grab the excellent Jasmine JavaScript BDD test framework via its gem – you can use the framework of your just but I find Jasmine both pleasant to deal with and it generally Just Works. This just installs a few gems that we’re going to use for our tests. ![]() Guard-livereload terminal-notifier-guard -no-rdoc -no-ri TERMINAL NOTIFIER GUARD INSTALLGem install jasmine jasmine-headless-webkit guard-jasmine-headless-webkit guard \ ![]() Let’s start by making sure we have all the gems we need: It has a great ecosystem around it which makes automating filesystem-based triggers both simple and powerful. Guard is a simple ruby gem that scans your file system for changes and runs the code of your choice whenever a file you care about is saved. Because I’ve used a lot of ruby I’m most comfortable using its ecosystem to achieve this, and as it happens there’s a great way to do this already. This was a fantastic way to work, and I wanted to get there again with JavaScript. One of the things I really loved about Rails in the early days was that it introduced me to the concept of autotest – a script that would watch your file system for changes and then automatically execute your unit tests as soon as you change any file.īecause the unit test suite typically executes quickly, you’d tend to have your test results back within a second or two of hitting save, allowing you to remain in the editor the entire time and only break out the browser for deeper debugging – usually the command line output and OS notifications (growl at the time) would be enough to set you straight. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |