Blog2013 ≫ Vows skeleton test generator update

Updated my Vows skeleton test generator for node.js so it now parses the original file looking for comments that say what the method should return, like phpunit does 1. For examples, see the source code and tests it creates:

/**
 * @assert ( 'foo' ) === 'foo'
 * @assert ( 66 ) === '66'
 */

creates

vows.describe( 'skelgen' ).addBatch( {
  'skelgen.sanitise': {
    'handles good input': function ( ) {
      assert.deepEqual( skelgen.sanitise('foo'), 'foo' );
      assert.deepEqual( skelgen.sanitise(66), '66' );
    },
    'handles bad input': function ( ) {
      assert.doesNotThrow(
        function ( ) {
          skelgen.sanitise( 'foo' );
          skelgen.sanitise( 66 );
          skelgen.sanitise( undefined );
          skelgen.sanitise( null );
          skelgen.sanitise( [] );
          skelgen.sanitise( {} );
          skelgen.sanitise( new Date( ) );
        }
      );
    }
  }
} ).run( );

See the repo for how to install it and use it.

All those links to twitter are not relevant, just something that coincidentally looks like a twitter account...

UPDATE: wow this is old I don't code like this any more, nor use Vows.

  1. Removed old phpunit.de/manual/3.4/en/appendixes.annotations.html#appendixes.annotations.assert link here.

nodejs: Js (programming language of the internets) on the server side.

js: Programming language of the internets, mostly how I make my living.

⬅️ :: ➡️

Paulʼs weblog - I live in A sleepy town, Kent. Married + dad to two, I am a full stack web developr, and I do javascript / node, some ruby, other languages etc. My hobbies are pubbing, parkrun, restaurants, home automation + other diy stuff, history, tree stuff, telly 📺, squirrels, pirates ☠️, lego, and TIME TRAVEL.