NodeJS Console Object Debug Inspector - Thomas Hunter - Web Development Tutorials and Personal Opinions. The NodeJS Console Object Debug Inspector, or simply node-codein, is a tool for providing a visual debugger of global node variables, as well as executing code inside of your running process. Think of it as a GUI REPL for a running node process. This GUI is run in a browser (it works best with Chrome, maybe only with Chrome). It provides expandable and collapsable nodes when dealing with hierarchal data, has syntax highlighting depending on the type of data involved. It will mirror your console.log() commands (they are shown in both the terminal as well as the GUI).
One thing I really like is how easy it is to use; simply require the module from your project, you don’t otherwise need to write any special code to make it work (save for the gotcha’s below). The interface feels a lot like the JavaScript console provided in modern browsers. Getting node-codein The project is hosted at github/ketamynx/node-codein. Npm install node-codein -g Example Usage Code Terminal Output Screenshot Gotcha’s. Building a Text-Based UI with Backbone and Charm. I am a little framework averse. When I write a program, I like to build from scratch as far as it is practical.
Not using a framework gives me the feeling that I am so in control of my own destiny. But having said that, I will sometimes succumb to using a framework when it's very clear that the use of the framework will result in significantly less code, and/orsignificantly less complexity I recently rewrote a text-based user interface using Backbone, and as far as I know, that is a framework. This is story of how that all went down. The Problem I was working on the user interface for Testem - a test runner for Javascripts written in Node. The most interesting aspect of the UI is the tabbed interface.
Here are some of the events the tab interface will have to handle In short, the UI is very event driven. The "Before" First, I will get you acquainted with a piece of the code before the rewrite has taken place. Charm The text-based UI was written using Substack's excellent Charm library. Why MVC? CasperJS, a navigation scripting and testing utility for PhantomJS | CasperJS 1.0.0-RC1. Front-end Unit Testing with JavaScript | Danny Croft - Web Developer made in Wales but working in London Unit testing can make your code less prone to bugs and gives you piece of mind that everything is working the way it should.
Normally when I speak to other developers about work, we end up speaking about workflow, tools and release processes. I’m always surprised by the amount of front-end developers that don’t unit test their code. When asked why, they give the following answers: “I did have a look at Selenium, but it freaked me out. Getting it installed and ready to go looked a right pig!” “The back-end guys usually just do that” “I don’t really get time to do any of that kind of stuff but I’d like to” “Unit Testing? So rounding up the problems that people are facing, we get the following: Time and effort it takes to get setupComplex APIs and steep learning curvesGeneral lack of exposure Introducing PhantomJS & CasperJS PhantomJS is a headless WebKit with JavaScript API.
If you’re thinking “headless WebKit??!!?” Both are really easy to use and extremely powerful! Getting Started! Requirements: Vows and CoffeeScript. CoffeeScript is a really nice way to write JavaScript code. Combined with NodeJS you are empowered by a very fast platform to develop server-side applications. Of course, you want to test these apps as well. Vows is really great way to do this. Unfortunately it's not straight forward (yet) to set up NodeJS + CoffeeScript + Vows. ~ First off, make sure you have CoffeeScript and Vows installed.
Npm install -g coffee-script npm install -g vows Next up, in your product directory, create a directory named test. I'm not going to explain the intimate details of Vows here, suffice it to say that you calculate a value and store it in topic. The magic part is the last line, .export(module). When using coffee-script, you don't want to directly run you vows, but gather them all together, convert them to JavaScript and then have vows run them. With the test/division-test.coffee saved, try running vows from your console. Another great tip is vows -w. Happy testing! Did you enjoy this post? Vows « Asynchronous BDD for Node. Coffeescript, Jasmine and Katas | Caffeine Industries. Posted in code, Javascript, Language, Programming, Uncategorized on Saturday, March 10th, 2012 at 2:07 pm Hey-O! CoffeeScript is nice. It provides syntactic sugar and adds tremendous functionality to the web developers tool-chest.
Those who appreciate terse, yet readable and well formatted code; CoffeeScript will seem like a manna from heaven. I find that I am already looking at my JavaScript and refactoring it in my head to CoffeeScript. On long road trips I generally have a few hours to kill while the rest of the family is asleep. This trip I decided to load my Galaxy Nexus with a metric ton of CoffeeScript screen casts (just audio) and podcasts. Since I’ve returned home, I have decided to stick with CoffeeScript and add a few more.
I’ve also become a believer in dedicated, deliberate practice. I used this code kata with CoffeeScript and Jasmine. Click the post image to see the passing tests! Here is my solution: The Spec’s in CoffeeScript The implementation in CoffeeScript: