grunt-contrib-nodeunit icon indicating copy to clipboard operation
grunt-contrib-nodeunit copied to clipboard

Passing values from grunt to nodeunit tests

Open creynders opened this issue 11 years ago • 4 comments

Is it possible? It would be really handy when testing grunt tasks.

creynders avatar Feb 25 '14 18:02 creynders

@creynders Could you post an example configuration for this and describe a little more clearly what you're hoping to do?

tkellen avatar Mar 14 '14 13:03 tkellen

Maybe something like this:

nodeunit:{
    tests : {
        values : {
            foo : 'bar'  
        },
        options:{
            //options
        }
    }
}

In which case foo would be injected into all relevant tests. I encountered it first when working on grunt_generate_configs where my npm test consisted out of multiple runs of the grunt task with different flags. However I needed to be able to access those flags in my tests as well to verify the correct functioning of the task. In the end I solved it by storing the flags in process.env and having the tests access them there. Certainly doable, but it would've been nicer to have been able to access them directly.

creynders avatar Mar 15 '14 07:03 creynders

+1 came here looking exactly for that

ruyadorno avatar Jul 16 '14 22:07 ruyadorno

looking for a solution to this as well

AHaliq avatar May 20 '16 15:05 AHaliq