Grunt and hood.ie test database

I am currently running my test suite on AngularJS using Grunt , Karma , Jasmine and Protractor . I am using the hood.ie database library , which is a library on top of CouchDB . I am running hood.ie using the following code in my grunt file:

hoodie: { start: { options: { callback: function(config) { grunt.config.set('connect.proxies.0.port', config.stack.couch.port); } } } }, 

However, I would like to have a separate database for running tests, which is automatically reset subsequently. Thus, production data will not conflict with tests.

How do I approach this? I would suggest that there is some standard way to do this, as I can imagine that other people are facing the same problem, but I cannot find anything on the Internet.

+8
javascript couchdb gruntjs jasmine hoodie
source share
2 answers

This currently seems impossible, since the hoodie server does not support it. The best way to do this is to change it yourself on the Hood.ie Github repository server , adding a parameter to determine the folder in which the data will be saved, which is currently rigidly tied to the "data" ( https://github.com/hoodiehq/hoodie -server / blob / master / lib / core / environment.js # L48 )

Something similar to this should work:

 app_path: path.resolve(project_dir, argv.folder || 'data') 
+2
source share

Since the hoodie task is "multitasking," you might have a test target in your hunt.ie grunt task specific to testing, and then reference it in the grunt command used to run the tests, for example:

 hoodie: { start: { options: { callback: function(config) { grunt.config.set('connect.proxies.0.port', config.stack.couch.port); } } }, test: { options: { callback: function(config) { // Make test specific changes here. } } } } // The task that runs tests first starting test deps. 'runtests' can be anything you want. grunt.registerTask('test', 'Run unit tests', ['hoodie:test', 'runtests']); 

Note: this will mean that at any other time when you refer to the hoodie task, you need to be explicit, because otherwise all of the specified goals will be launched. See the documentation for multitasking resources for more information . In this example, you would change hoodie to hoodie: start the "start" task as previously defined.

0
source share

All Articles