0

I have to run tests against a JavaScript file using grunt framework.

Just needed any simple example to do this, the target file (/test/filename.js) has dependencies on one more file.

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
user1400915
  • 1,933
  • 6
  • 29
  • 55
  • If I understood you right, you need to lint your javascript with some kind of JsHint, using grunt? – Andrew Shustariov Apr 22 '14 at 10:16
  • I have written code in .js files and placed it in /test folder . Now I want to run these test files to check if they are executing using grunt – user1400915 Apr 22 '14 at 10:27
  • Which testing frameworks have you investigated or tried? If you've written tests, which test syntax have you used? Are you looking for an answer that, for instance, tells you to go use Karma test runner with the Jasmine testing syntax and to append `jasmine-jquery` to it all mixed with requirejs? – Jason Aller Apr 22 '14 at 13:59
  • I just need to run a file called /test/filename.js using grunt which internally will run some five test files. – user1400915 Apr 22 '14 at 14:31
  • I don't need to use any of the frameworks, as I am running on node js framework, I just need to invoke files from grunt... – user1400915 Apr 22 '14 at 14:32

1 Answers1

0

Basically you have to make use of grunt-execute command.

Here is the explaination:https://www.npmjs.org/package/grunt-execute

In simple words , this is what you should do for your specific requirement:

module.exports = function(grunt) {

   grunt.initConfig({

    execute: {
        simple_target: {
            // execute javascript files in a node child_process
            src: ['filename.js']
        }

    }
})


grunt.loadNpmTasks('grunt-execute');
grunt.registerTask('default', ['execute']);

}

And also,

"grunt": "~0.4.4",
 "grunt-execute": "~0.1.5" 

should be present in package.json, then just do npm install

user1907849
  • 960
  • 4
  • 19
  • 42