samedi 9 janvier 2016

grunt task src filtering from cli

I have a grunt task that runs all of my nodejs server side test files.

grunt.registerTask('serverTest', ['env:test', 'mongoose', 'mochaTest']); 

While developing tests I would like to only run the test I'm currently working on. My task is setup to run a list of all test assets in the code base:

mochaTest: {
        src: testAssets.tests.server,
        options: {
            reporter: 'spec'
        }
    },

I would like to specify a filter parameter at the cli to only select a specific file from testAssets.tests.server which is a big list of tests since it's defined as modules/*/tests/server/**/*.js and returns every test in the code base.

For example if I entered the following at the command line:

grunt serverTest:*fileUnderTest.js

Grunt would filter the testAssets.tests.server and only execute the files that match *fileUnderTest.js

I've read through the documentation and seen a lot of examples but can't figure out how to do this without creating a separate target and specifying the file name in the grunt file.

Aucun commentaire:

Enregistrer un commentaire