diff options
| author | Zog | 2017-12-26 09:55:21 +0100 |
|---|---|---|
| committer | Zog | 2017-12-27 09:14:06 +0100 |
| commit | 54e6052b18a5451ed962dfaade88f8de28972e76 (patch) | |
| tree | c0928fd6f6a70566dea6caef3ca4d1ca41b640c7 /Gruntfile.coffee | |
| parent | fdae84e447a09e8dac6b7f3167a35c209db342a6 (diff) | |
| download | chouette-core-54e6052b18a5451ed962dfaade88f8de28972e76.tar.bz2 | |
Refs #5376 @1h; Add setup for javascript specs
Use grunt to automagically run the specs
Diffstat (limited to 'Gruntfile.coffee')
| -rw-r--r-- | Gruntfile.coffee | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/Gruntfile.coffee b/Gruntfile.coffee new file mode 100644 index 000000000..16b55e8ef --- /dev/null +++ b/Gruntfile.coffee @@ -0,0 +1,47 @@ +module.exports = (grunt) => + javascriptSpecPath = (path) -> + grunt.log.writeln "IN: " + path + path = path.replace 'app/javascript', 'spec/javascript' + if path.match /actions/ + path = path.replace /actions.*/, 'actions_spec.js' + if path.match /reducers/ + path = path.replace '.js', '_spec.js' + grunt.log.writeln "OUT: " + path + path + + grunt.initConfig + pkg: grunt.file.readJSON('package.json') + watch: + javascripts: + files: ['app/javascript/**/*', 'spec/javascript/**/*'] + tasks: [] + options: + spawn: false + + watchchange: + javascript: + match: ['app/javascript/**/*', 'spec/javascript/**/*'] + setConfig: ['jest.run.src'] + preprocess: javascriptSpecPath + tasks: ['jest:run'] + + jest: + run: + files: [] + + grunt.loadNpmTasks('grunt-contrib-watch') + grunt.loadNpmTasks('grunt-watch-change') + + # Default task(s). + grunt.registerMultiTask 'jest', 'run javascript specs', () -> + files = [] + this.files.forEach (file) -> + files.push file.src + grunt.log.writeln files + grunt.util.spawn + cmd: 'node_modules/.bin/jest' + args: files + opts: {stdio: 'inherit'} + , -> {} + + grunt.registerTask 'default', ['watchchange', 'watch'] |
