-
Notifications
You must be signed in to change notification settings - Fork 0
stvn/Ernest
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Writing tests is simple an easy with Ernest! Example: Start by requiring the Ernest module. Path may need to be altered depending on location of test files. var ernest = require(‘geddy/geddy-core/scripts/ernest’); var assert = require('assert); Create an namespace (object-literal) to wrap your tests. var myTests = { //preface each key with the word ‘test’ testThatSomethingWorks : function(){ var foo = ‘bar’; //use Node’s Assert module — last parameter is fail message that is displayed. //By default, it uses what’s predefined in Ernest assert.ok(foo, this.fail); assert.equal(foo, ‘bar’, this.fail); } }; And, for the last bit, pass your new test to Ernest: ernest.execute(myTests); If you want tests to be run via ‘make test’ — Save your tests in a directory called ‘tests’ in the module you’re testing. That’s it!!! It’s that easy! Tests can be run one of two ways: run all tests: make test individual tests: node path/to/test.js Additionally I've included an example of tests that are actively being used in Geddy (http://www.github.com/mde/geddy).
About
Lightweight Javascript Test Runner for Node.js
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published