happner tests
we have a standard test that we inject a bunch of different contexts through, so if you happner to build a plugin for happner - you would use this test suite to ensure your code is up to standard.
getting started:
npm install happner-tests
the create a tests directory, in that directory create a "happner_test.js" file and a "context" folder - the happner_test.js file sets up the happner-tests suite and call's its run method, in the example below, a TEST_GLOBALS object is also created, so that contexts are able to use properties on the TEST_GLOBALS later:
happner_test.js:
//this is specific to the project you are testing - this code is borrowed from the mongo plugin for happnerTEST_GLOBALS = {}; var service = ;var serviceInstance = ; var config = url:'mongodb://127.0.0.1:27017/happner' serviceInstance;
contexts
the contexts are little modules that supply the tests with configurations that are being tested against, here is an example context file for the 01-vanilla test:
var happner = var happner_client = happnerclient; moduleexports = //the test needs a required happner module happnerDependancy: //some additional information if you want - just used to console.log out description:"eventemitter embedded functional tests" //the happner service configuration - we are going for default vanilla here serviceConfig:{} //this specific test needs a happner client in a specific configuration - in this case in EventEmitter mode { var config = plugin: happnerclient_pluginsintra_process context: happnerInstance happner_client; } //this specific test needs a happner client in a specific configuration - in this case in EventEmitter mode { var config = plugin: happnerclient_pluginsintra_process context: happnerInstance happner_client; }
you save your context file as 01-vanilla-[my context name].js in the context folder. you are now A for away and can test, using node like so:
node test/happner_test.js
*NB: if you are already running mocha tests, it is fine to locate your happner_test file elsewhere - so you dont get instances where the tests are automatically run causing issues, you can also update your package.json to run mocha tests and then the happner_test file, as follows: *
this was again borrowed from the happner mongo service's package.json.