Answer the question
In order to leave comments, you need to log in
How to run a test with webpack + karma?
I'm trying to run tests in karma. I am getting an error:
SyntaxError: Use of reserved word 'export'
at D:/projects/florida/src/index.spec.js:8143 <- webpack:///src/index.js:3:0
"use strict";
const root = __dirname + "/src";
const params = {
basePath: 'src',
files: [
"**/*.spec.js"
],
reporters: ["mocha"],
frameworks: ["mocha", "chai"],
preprocessors: {
"**/*.spec.js": ["webpack", "sourcemap"]
},
browsers: ["PhantomJS"],
colors: true,
singleRun: true,
webpackMiddleware: {
noInfo:true
}
};
params.plugins = [
"karma-webpack",
"karma-mocha",
"karma-chai",
"karma-phantomjs-launcher",
"karma-mocha-reporter",
"karma-sourcemap-loader"
];
params.webpack = {
module: {
preLoaders: [
{
test: /\.spec\.js$/,
include: root,
exclude: /node_modules/,
loader: 'babel',
query: {
"presets": ["es2015"],
}
}
],
loaders: [
{
test: /\.js$/,
include: root,
exclude: /node_modules/,
loader: "babel",
query: {
"presets": ["es2015"]
}
}
]
},
resolve: {
modulesDirectories: ["node_modules"],
extensions: ["", ".js"]
},
devtool: "inline-source-map",
cache: true
};
module.exports = function(config) {
config.set(params);
};
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question