Thursday, May 2, 2013

Running mocha scripts has nothing to do with the Node shell as it turns out.

Per this I typed npm install -g mocha followed by mkdir test at the Command Prompt in Windows 8 which, for me, by default spins up at C:\Users\Thomas so I suppose I both installed mocha therein and created a directory called "test" for mocha to crawl. In the test directory I manually made a file called test.js with this inside of it (taken from the page I link to):

var assert = require("assert")
describe('Array', function(){
   describe('#indexOf()', function(){
      it('should return -1 when the value is not present', function(){
         assert.equal(-1, [1,2,3].indexOf(5));
         assert.equal(-1, [1,2,3].indexOf(0));
      })
   })
})

 
 

I returned to the Command Prompt and typed mocha and was able to run the test successfully. I returned to file I made and changed the five to a two and then ran the test again to see it fail. Yay!

Addendum 5/3/2013: See this as the very title of this blog posting is bad.

No comments:

Post a Comment