0

How do I run my 'test' npm script using Grunt? It says here that I can do it using grunt-run.

package.json

 .
 .
 "scripts": {
   "test": "jest"
   },
"jest": {
  "preset": "jest-exponent"
 }

.
.
.


"devDependencies": {
  "babel-jest": "^17.0.0",
  "babel-preset-react-native": "^1.9.0",
  "grunt": "^1.0.1",
  "grunt-run": "^0.6.0",
  "jest-exponent": "^0.1.3",
  "jest-react-native": "^17.0.0",
  "react-test-renderer": "^15.3.2"
}

Gulpfile.js - boilerplate code

module.exports = function(grunt) {
  grunt.initConfig({
   run: {
     options: {
       // Task-specific options go here.
     },
     your_target: {
       cmd: 'executable',
        args: [
               'arg1',
               'arg2'
        ]
     }
  }
})

}

What is the point of Grunt/Gulp if you can just use npm scripts? They require a lot less set up and do the same thing.

Sam Henderson
  • 479
  • 5
  • 7
  • 1
    I think you answered your own question. If all you're doing is executing scripts then you don't need grunt or gulp. – azium Nov 11 '16 at 22:49
  • Check this answer, worked for me! https://stackoverflow.com/a/47304117/5346095 – Peter Nov 16 '17 at 09:22

1 Answers1

0

not sure if that will helps you, you need install first the task grunt-exec, in my sample i am runing a node server.js

this in my config.

Gruntfile.js

config.exec = {
         run_server: 'node server.js'
}
grunt.registerTask('serve', ['exec:run_server']);

package.json

 "grunt-exec": "^1.0.1",
raduken
  • 2,091
  • 16
  • 67
  • 105