Browse Source

AMBARI-19215 Integrate karma with babel preprocessor. (atkach)

Andrii Tkach 9 years ago
parent
commit
791a24cda0
2 changed files with 32 additions and 16 deletions
  1. 16 3
      ambari-web/karma.conf.js
  2. 16 13
      ambari-web/package.json

+ 16 - 3
ambari-web/karma.conf.js

@@ -29,7 +29,8 @@ module.exports = function(config) {
       'karma-phantomjs-launcher',
       'karma-coverage',
       'karma-ember-precompiler-brunch',
-      'karma-commonjs-require'
+      'karma-commonjs-require',
+      'karma-babel-preprocessor'
     ],
 
     // frameworks to use
@@ -114,8 +115,20 @@ module.exports = function(config) {
     preprocessors: {
       '!(vendor|node_modules|test)/**/!(karma_setup|tests).js': 'coverage',
       'app/templates/**/*.hbs': ['ember-precompiler-brunch', 'common-require'],
-      'app!(assets)/**/!(karma_setup|tests).js': ['common-require'],
-      'test/**/*.js': ['common-require']
+      'app!(assets)/**/!(karma_setup|tests).js': ['common-require', 'babel'],
+      'test/**/*.js': ['common-require', 'babel']
+    },
+
+    babelPreprocessor: {
+      options: {
+        presets: ['es2015']
+      },
+      filename: function (file) {
+        return file.originalPath.replace(/\.js$/, '.js');
+      },
+      sourceFileName: function (file) {
+        return file.originalPath;
+      }
     },
 
     // list of files to exclude

+ 16 - 13
ambari-web/package.json

@@ -21,22 +21,25 @@
     "assetsmanager-brunch": "~1.8.1"
   },
   "devDependencies": {
-    "phantomjs": "~2.1.0",
-    "mocha":"2.5.3",
-    "mocha-phantomjs": "~4.1.0",
-    "mocha-phantomjs-core": "~2.1.0",
-    "chai":"~3.5.0",
-    "sinon":"=1.7.3",
-    "sinon-chai":"~2.8.0",
-    "express":"2.5.8",
+    "babel": "^6.5.2",
+    "babel-preset-es2015": "^6.18.0",
+    "chai": "~3.5.0",
+    "express": "2.5.8",
     "karma": ">=0.11.14",
-    "karma-mocha": "0.1.1",
+    "karma-babel-preprocessor": "^6.0.1",
     "karma-chai": "~0.1.0",
-    "karma-sinon": "~1.0.2",
-    "karma-phantomjs-launcher": "1.0.2",
-    "karma-coverage": "~0.2.0",
     "karma-commonjs-require": "~0.0.1",
-    "karma-ember-precompiler-brunch": "^1.0.0"
+    "karma-coverage": "~0.2.0",
+    "karma-ember-precompiler-brunch": "^1.0.0",
+    "karma-mocha": "0.1.1",
+    "karma-phantomjs-launcher": "1.0.2",
+    "karma-sinon": "~1.0.2",
+    "mocha": "2.5.3",
+    "mocha-phantomjs": "~4.1.0",
+    "mocha-phantomjs-core": "~2.1.0",
+    "phantomjs": "~2.1.0",
+    "sinon": "=1.7.3",
+    "sinon-chai": "~2.8.0"
   },
   "scripts": {
     "start": "brunch watch --server",