reactjs - Syntax error when testing React component Jasmine and Webpack -


i keep getting error when trying run simple test using react, karma, jasmine , webpack. error ' uncaught syntaxerror: unexpected token < ', think jsx isn't being processed js, don't know why happening understand webpack should handle using babel loader. if can provide advice grateful

here files

karma.conf.js

var webpack = require("webpack"),   path = require("path");  // karma configuration  module.exports = function(config) {   config.set({     basepath: "",     frameworks: ["jasmine"],     files: [       "../test/!**!/!*.test.js"     ],     preprocessors: {       "./test/!**!/!*.test.js": ["webpack"]     },     webpack: {       module: {           loaders: [       {         test: /\.jsx?$/i,         loader: 'babel-loader',         query: {           presets: ['react', 'es2015', 'stage-1']         }       },       { test: /\.less$/, loader: "style!css!less" }     ]   },       },       plugins: [         new webpack.resolverplugin([           new webpack.resolverplugin.directorydescriptionfileplugin("bower.json", ["main"])         ])       ],       resolve: {         root: __dirname,         extensions: [           '',           '.json',           '.js',           '.jsx'         ]       }     },     webpackmiddleware: {       noinfo: true     },     plugins: [       require("karma-webpack"),       require("karma-jasmine"),       require("karma-chrome-launcher")     ],     reporters: ["dots"],     port: 9876,     colors: true,     loglevel: config.log_info,     autowatch: true,     browsers: ["chrome"],     singlerun: false   }); }; 

my test file example.test.js

var comp = require('../../../js/common/components/mycomp.jsx'),   react = require('react'),   testutils = react.addons.testutils;  describe("component test", function() {   it("renders h1", function () {     var component = testutils.renderintodocument(       <comp/> // syntax error here     );      var h2 = testutils.findrendereddomcomponentwithtag(       component, 'h2'     );      expect(h1).toexist();   }); }); 

so syntax error happens @ < comp... . thanks!

apologise error in setting correct path test file.

files: [   "../test/**/*.test.js" ], preprocessors: {   "../test/**/*.test.js": ["webpack"] }, 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -