I received an the following error:
Cannot find module "../controllers/loginCtrl" when running karma, controller file in src/controllers, test file in src/tests
1) karma.conf.js:
var path = require('path');
var hasCoverage = global.process.argv.reduce(function (result, arg) {
return arg.indexOf('coverage') !== -1 || result;
});
var include = [
path.resolve('./src')
];
var preLoaders = hasCoverage ? [
// Process test code with Babel
{test: /\.spec\.js$/, loader: 'babel', include: include},
// Process all non-test code with Isparta
{test: /\.js$/, loader: 'isparta', include: include, exclude: /\.spec\.js$/}
] : [
{test: /\.js$/, loader: 'babel', include: include}
];
var loaders = [
{test: /\.sass$/, loader: 'style!css?sourceMap!sass?sourceMap&indentedSyntax=true'},
{test: /\.png$/, loader: 'null'},
{test: /\.jpg$/, loader: 'null'},
// Loader for JSON, may be used in some tests
{test: /\.json$/, loader: 'json'},
// Need some real loaders for HTML, because angular directives are coupled with templates
{test: /\.haml$/, loader: 'hamlc-loader'},
{test: /\.html$/, loader: 'ng-cache?prefix=[dir]/[dir]'}
];
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine'],
plugins: [
'karma-babel-preprocessor',
'karma-jasmine',
'karma-webpack',
'karma-phantomjs-launcher',
'karma-chrome-launcher',
],
files: [
'spec.js',
],
webpack: {
devtool: 'eval',
module: {
loaders: loaders,
preLoaders: preLoaders
},
cache: true
},
webpackMiddleware: {
stats: {
chunkModules: false,
colors: true
}
},
preprocessors: {
'spec.js': ['webpack'],
},
babelPreprocessor: {
options: {
presets: ['es2015'],
sourceMap: 'inline'
},
filename: function (file) {
return file.originalPath.replace(/\.js$/, '.es5.js');
},
sourceFileName: function (file) {
return file.originalPath;
}
},
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: false,
browsers: ['PhantomJS'],
singleRun: true
});
};
2) spec.js:
var testsContext;
require('babel-polyfill');
require('angular');
require('angular-mocks');
testsContext = require.context('./src/', true, /\.spec\.js$/);
testsContext.keys().forEach(testsContext);
3) LoginCtrl.spec.js:
import LoginCtrl from '../controllers/loginCtrl';
describe('controller: LoginCtrl', function() {
let scope;
let ctrl;
beforeEach(function() {
angular.module('envio', [])
.controller('LoginCtrl', LoginCtrl);
});
beforeEach(angular.mock.module('envio'));
beforeEach(angular.mock.inject(function($controller, $rootScope) {
scope = $rootScope.$new();
ctrl = $controller('LoginCtrl', {
$scope: scope
});
}));
it('should set message to null', function() {
expect(ctrl).toBeDefined();
// expect(scope.message).toBeNull();
});
});
How can I prevent this error?
Related
Hey I am trying to use ui-router-metatags module in my project but it never works.
https://github.com/tinusn/ui-router-metatags
I followed the steps but at the end nothing. it is not showing error even.
I use yeoman fountain js generator for angular js and webpack.
I do npm install ui-router-metatags --save
this is my index.js file
var angular = require('angular');
var techsModule = require('./app/modules/techs/index');
require('angular-ui-router');
require('expose-loader?$!jquery');
var routesConfig = require('./routes');
var main = require('./app/main');
var header = require('./app/shared/header');
var title = require('./app/shared/title');
var footer = require('./app/shared/footer');
import 'bootstrap';
require('./index.scss');
angular
.module('app', [techsModule, 'ui.router', 'ui.router.metatags'])
.config(routesConfig)
.component('app', main)
.component('fountainHeader', header)
.component('fountainTitle', title)
.component('fountainFooter', footer);
function runBlock($rootScope, MetaTags) {
$rootScope.MetaTags = MetaTags;
}
angular
.module('app')
.run(['$rootScope', 'MetaTags', runBlock]);
function myService() {
var service = {
getPosts: getPosts,
getPost: getPost
};
var samplePost = {
id: 1,
title: 'sample blog post',
content: 'lorem ipsum'
};
function getPosts(category) {
return [samplePost];
}
function getPost(id) {
return samplePost;
}
return service;
}
angular
.module('app')
.service('myService', myService);
and my routes.js look like that.
module.exports = routesConfig;
/** #ngInject */
function routesConfig($stateProvider, $urlRouterProvider, $locationProvider, UIRouterMetatagsProvider) {
$locationProvider.html5Mode(true).hashPrefix('!');
UIRouterMetatagsProvider
.setTitlePrefix('prefix - ')
.setTitleSuffix(' | MyApp')
.setDefaultTitle('MyApp')
.setDefaultDescription('description')
.setDefaultKeywords('keywords')
.setStaticProperties({
'fb:app_id': 'your fb app id',
'og:site_name': 'your site name'
})
.setOGURL(true);
$urlRouterProvider.otherwise('/');
$stateProvider.state('app', {
url: '/',
component: 'app',
metaTags: {
title: 'Frontpage',
description: 'This is the frontpage',
keywords: 'lots of interresting keywords',
properties: {
'og:title': 'Frontpage'
}
}
});
}
and for my html page I use this:
<title ng-bind="MetaTags.title">Default title</title>
<meta name="description" content="{{MetaTags.description}}">
<meta name="keywords" content="{{MetaTags.keywords}}">
<meta ng-repeat="(key, value) in MetaTags.properties" property="{{key}}" content="{{value}}">
<meta name="prerender-status-code" content="{{MetaTags.prerender.statusCode}}">
<meta name="prerender-header" ng-if="MetaTags.prerender.header" content="{{MetaTags.prerender.header}}">
and for my web pack config I have this:
const webpack = require('webpack');
const conf = require('./gulp.conf');
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const FailPlugin = require('webpack-fail-plugin');
const autoprefixer = require('autoprefixer');
module.exports = {
module: {
rules: [
{
test: require.resolve('jquery'),
use: [
{loader: 'expose-loader', options: 'jQuery'},
{loader: 'expose-loader', options: '$'}
]
},
{
test: require.resolve('tether'),
use: [
{loader: 'expose-loader', options: 'Tether'}
]
},
{
test: /\.json$/,
loaders: [
'json-loader'
]
},
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'eslint-loader',
enforce: 'pre'
},
{
test: /\.(css|scss)$/,
loaders: [
'style-loader',
'css-loader',
'sass-loader',
'postcss-loader'
]
},
{
test: /\.js$/,
exclude: /node_modules/,
loaders: [
'ng-annotate-loader'
]
},
{
test: /\.html$/,
loaders: [
'html-loader'
]
}
],
loaders: [
{
test: /\.json$/,
loaders: [
'json-loader'
]
},
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'eslint-loader',
enforce: 'pre'
},
{
test: /\.(css|scss)$/,
loaders: [
'style-loader',
'css-loader',
'sass-loader',
'postcss-loader'
]
},
{
test: /\.js$/,
exclude: /node_modules/,
loaders: [
'ng-annotate-loader'
]
},
{
test: /\.html$/,
loaders: [
'html-loader'
]
},
{test: require.resolve('jquery'), loader: 'expose-loader?$'}
]
},
plugins: [
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
FailPlugin,
new HtmlWebpackPlugin({
template: conf.path.src('index.html')
}),
new webpack.LoaderOptionsPlugin({
options: {
postcss: () => [autoprefixer]
},
debug: true
}),
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery',
tether: 'tether',
Tether: 'tether',
'window.Tether': 'tether',
Popper: ['popper.js', 'default'],
// In case you imported plugins individually, you must also require them here:
Util: 'exports-loader?Util!bootstrap/js/dist/util',
Dropdown: 'exports-loader?Dropdown!bootstrap/js/dist/dropdown'
})
],
devtool: 'source-map',
output: {
path: path.join(process.cwd(), conf.paths.tmp),
filename: 'index.js'
},
node: {
fs: 'empty'
},
entry: `./${conf.path.src('index')}`
};
I am trying to make my first JS unit test with Karma and Jasmin. I am testing a react app.
I generated the karma config with "karma init" and modified it, see below for the karma.config.js
The webpack.config is required in the karma.config.js, but the babel loader is completely ignored, why?
I noticed it's ignored as it resulted in errors of undefined variable, etc...
When adding parts of the webpack.config.js directly in the karma.config.js (copy/paste), it works, but that is not what I want as I am duplicating code like my loaders and aliases, etc... How to solve this? See below also the webpack.config.js
The karma.config.js:
module.exports = function (config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: 'src/js/',
frameworks: ['jasmine'],
files: [
'tests/*.test.js',
],
preprocessors: {
'**/tests/*.test.js': ['webpack', 'sourcemap'],
},
webpack: require("../webpack.conf.js"),
webpackMiddleware: {
stats: "errors-only"
},
reporters: ['progress'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['PhantomJS'],
phantomJsLauncher: {exitOnResourceError: true},
singleRun: false,
concurrency: Infinity
})
};
The webpack.config.js:
module.exports = function (env) {
if (env !== undefined) {
let analyse = !!env.analyse;
console.log("Analyse?: " + analyse);
if (analyse) {
plugins.push(new BundleAnalyzerPlugin({analyzerMode: 'static'}));
}
}
return {
entry: {
entry: ['./src/entry.js', './src/js/utils.js'],
},
devtool: devTool,
devServer: devServer,
output: {
path: __dirname + '/dist',
filename: '[name]-[hash].cache.js', // it contains the name ".cache", that is used in the webserver config.
sourceMapFilename: '[name]-[hash].cache.js.map',
},
module: {
rules: [
{ // The Babel loader:
test: /(\.jsx|\.js)$/,
exclude: /(node_modules|bower_components)/,
use: [{
loader: 'babel-loader',
options: {
presets: ['babel-preset-es2015', 'babel-preset-react'].map(require.resolve),
plugins: ['babel-plugin-transform-react-jsx-img-import'].map(require.resolve) // It will convert the used images to to "require" statements such that it's used by a loader below.
}
}]
},
{
test: /\.s?css$/,
use: ['style-loader', 'css-loader', 'sass-loader']
},
{
test: /\.(png|gif|jpe?g)$/,
use: [{
loader: 'file-loader',
options: {
name: 'resources/images/[name]-[hash]-cache.[ext]'
}
}]
},
{
test: /\.(otf|svg|eot|ttf|woff2?)(\?.*$|$)/,
use: [{
loader: 'file-loader',
options: {
name: 'resources/fonts/[name]-[hash]-cache.[ext]'
}
}]
},
]
},
plugins: plugins,
externals: ['axios'],
resolve: {
alias: {
// Ref: https://webpack.js.org/configuration/resolve/
Context: path.resolve(__dirname, 'src/js/context'),
Utils: path.resolve(__dirname, 'src/js/utils'),
....etc...
},
}
};
};
in karma.config.js:
webpack: require("../webpack.conf.js")
you're giving "webpack" a function instead of an object. you should immediately invoke it (with or without an env param) require("../webpack.conf.js")()
When i carry out the angular test of the angularjs,i caught this error
You may need an appropriate loader to handle this file type.
| #import '../../sass/conf/conf';
| #import '../../components/baMsgCenter/baMsgCenter';
|
at karma-shim.js:174003
//webpack.test.js
var webpack = require('webpack');
var helpers = require('./config/helpers');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = {
devtool: 'inline-source-map',
resolve: {
extensions: ['.ts', '.js']
},
entry: {
},
module: {
rules: [
{
test: /\.ts$/,
loaders: [
{
loader: 'awesome-typescript-loader',
options: { configFileName: helpers.root('src', 'tsconfig.json') }
}, 'angular2-template-loader'
]
},
{
test: /\.html$/,
loader: 'html-loader'
},
{
test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico)$/,
loader: 'null-loader'
},
{
test: /\.css$/,
exclude: helpers.root('src', 'app'),
loader: 'null-loader'
},
{
test: /\.css$/,
include: helpers.root('src', 'app'),
loader: 'raw-loader'
}
]
},
plugins: [
new webpack.ContextReplacementPlugin(
// The (\\|\/) piece accounts for path separators in *nix and Windows
/angular(\\|\/)core(\\|\/)(esm(\\|\/)src|src)(\\|\/)linker/,
helpers.root('./src'), // location of your src
{} // a map of your routes
)
]
}
//strategyTables.component.spec.ts
describe('StrategyTables test',()=> {
var comp:StrategyTables;
var fixture:ComponentFixture<StrategyTables>;
var de: DebugElement;
var el: HTMLElement;
beforeEach(async(()=>{
TestBed.configureTestingModule({
declarations:[StrategyTables],
imports:[
FormsModule,
PaginationModule,
CommonModule,
NgaModule,
Ng2SmartTableModule,
DropdownModule,
ModalModule
//StrategysModule
],
providers:[
{provide:StrategyTablesService,useClass:MockStrategyTablesService},
{provide:Router,useClass:RouterStub},
{provide:Location,useClass:MockLocation}
]
}).compileComponents();
}));
beforeEach(()=>{
fixture = TestBed.createComponent(StrategyTables);
comp = fixture.componentInstance;
});
it('test function',()=>{
comp.getById(1);
expect(comp.detail.name).toEqual("aaa");
});
});
I don't know what result to it,and how to fix it.Does someone has encountered such problems, or know how to solve it?
My app works like a charm but I can't run my tests with
$ yarn test
# node node_modules/karma/bin/karma start ./karma.conf.js --single-run
Version
"angular-mocks": "~1.5.10",
"karma-webpack": "^2.0.1",
"webpack": "^1.14.0",
"webpack-dev-server": "^1.16.2",
Error
PhantomJS 2.1.1 (Linux 0.0.0) leave API service create(): should create a leave FAILED
Error: [$injector:unpr] Unknown provider: LeaveServiceProvider <- LeaveService
http://errors.angularjs.org/1.5.10/$injector/unpr?p0=LeaveServiceProvider%20%3C-%20LeaveService (line 4674)
static/app.min.js:4674:87
getService#static/app.min.js:4827:40
static/app.min.js:4679:49
getService#static/app.min.js:4827:40
injectionArgs#static/app.min.js:4852:69
invoke#static/app.min.js:4874:32
WorkFn#node_modules/angular-mocks/angular-mocks.js:3130:26
inject#node_modules/angular-mocks/angular-mocks.js:3100:46
test/leave.service.tests.js:55:23
loaded#http://localhost:9876/context.js:151:17
inject#node_modules/angular-mocks/angular-mocks.js:3097:28
test/leave.service.tests.js:55:23
loaded#http://localhost:9876/context.js:151:17
TypeError: undefined is not an object (evaluating '$httpBackend.expectPOST') in test/leave.service.tests.js (line 64)
test/leave.service.tests.js:64:16
loaded#http://localhost:9876/context.js:151:17
TypeError: undefined is not an object (evaluating '$httpBackend.verifyNoOutstandingExpectation') in test/leave.service.tests.js (line 114)
test/leave.service.tests.js:114:16
loaded#http://localhost:9876/context.js:151:17
PhantomJS 2.1.1 (Linux 0.0.0): Executed 1 of 5 (1 FAILED) (skipped 4) ERROR (0.042 secs / 0.01 secs)
Karma.conf.js
const webpack = require('webpack');
const webpackConfig = require('./webpack.config.js');
module.exports = function (config) {
config.set({
basePath: './',
frameworks: ['jasmine', 'mocha', 'chai'],
files: [
'./static/app.min.js',
'node_modules/angular-mocks/angular-mocks.js',
{pattern: 'test/leave.service.tests.js'}
],
preprocessors: {
'test/leave.service.tests.js': ['webpack']
},
webpack: {
module: webpackConfig.module,
plugins: webpackConfig.plugins
},
webpackMiddleware: {
stats: 'errors-only'
},
notifyReporter: {
reportEachFailure: true,
reportSuccess: false
},
plugins: [
'karma-phantomjs-launcher',
'karma-jasmine',
'karma-webpack',
'karma-mocha',
'karma-chai'
],
browsers: ['PhantomJS']
});
};
webpack.conf.js
const webpack = require('webpack');
const path = require('path');
module.exports = {
entry: {
app: './src2/app.js'
},
output: {
path: path.resolve(__dirname, './static'),
publicPath: '/static/',
filename: 'app.min.js'
},
plugins: [
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery',
moment: 'moment'
})
],
resolve: {
root: path.resolve('./src2'),
extensions: ['', '.js']
},
module: {
loaders: [
{test: /\.css$/, loader: 'style-loader!css-loader'},
{test: /\.scss$/, loader: 'style-loader!css-loader!sass-loader'},
{test: /\.html$/, loader: 'html-loader'},
{test: /\.woff(\?v=\d+\.\d+\.\d+)?$/, loader: 'url-loader?limit=8192&mimetype=application/font-woff'},
{test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/, loader: 'url-loader?limit=8192&mimetype=application/font-woff'},
{test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, loader: 'url-loader?limit=8192&mimetype=application/octet-stream'},
{test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: 'file-loader'},
{test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, loader: 'url-loader?limit=8192&mimetype=image/svg+xml'}
]
},
devServer: {
port: 8080,
proxy: {
'/api': {
target: {
host: '0.0.0.0',
protocol: 'http:',
port: 8000
}
}
}
}
};
test/leave.service.js
var chai = require('chai');
var assert = chai.assert;
describe('leave API service', function () {
var service;
var $httpBackend;
beforeEach(inject(function (_$httpBackend_, LeaveService) {
$httpBackend = _$httpBackend_;
service = LeaveService;
}));
it('create(): should create a leave', function (done) {
var foo = 'bar';
assert.equal(foo, 'bar');
done();
});
});
Question
What's the matter here ?
related: Karma-webpack+angular TypeError: undefined is not an object (evaluating '$httpBackend.expectPOST'
When an Angular controller or a service depends on another Angular object (service, factory, constant...), the injector will look for it in the providers list (an array of singleton constructors). If there is no injector, or the dependency does not exist, angular will exit with an error like the one you have (no provider xProvider for service x). This should be resolved by mocking the angular module and attach depending services to it (method 1), or instantiate your LeaveService with a function returning an object filled with methods as its dependency argument, like
// leave-service.spec.js
...
var FakeHttpService = function() {
return {
get: function(url) { return new Promise(); },
post: function(url, data) { return new Promise(); },
//...
};
};
var leaveService = new LeaveService(new FakeHttpService());
Next, when you do something like var res = leaveService.get(url), it should call the FakeHttpService get method.
You should read the Angular Documentation on $httpBackend for further details about testing services that use the $http service (method 1), and understand how the injector works in a test environment.
I went back to a really simple test and add complexity step by step until it fails. The solution was to:
inject my app angular.mock.module('app')
beforeEach(angular.mock.module('app'));
inject the dependencies with angular.mock.inject()
beforeEach(function () {
angular.mock.inject(function (_$httpBackend_, _LeaveService_) {
$httpBackend = _$httpBackend_;
service = _LeaveService_;
});
});
load the built app, angular-mock and the test/**/*.js in karma.conf.js:
files: [
'./static/app.min.js',
'node_modules/angular-mocks/angular-mocks.js',
{pattern: 'test/foo.service.tests.js'}
]
Full code below
foo.service.tests.js
var chai = require('chai');
var assert = chai.assert;
describe('leave API service', function () {
var service;
var $httpBackend;
beforeEach(angular.mock.module('app'));
beforeEach(function () {
angular.mock.inject(function (_$httpBackend_, _LeaveService_) {
$httpBackend = _$httpBackend_;
service = _LeaveService_;
});
});
it('create(): should create a leave', function (done) {
var foo = 'bar';
assert.equal(foo, 'bar');
done();
});
});
webpack.conf.js
const webpack = require('webpack');
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const HtmlWebpackHarddiskPlugin = require('html-webpack-harddisk-plugin');
module.exports = {
entry: {
app: './src/app.js'
},
output: {
path: path.resolve(__dirname, './static'),
publicPath: '/static/',
filename: '[name]-[hash:8].min.js'
},
plugins: [
new webpack.optimize.ModuleConcatenationPlugin(),
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
moment: 'moment',
Util: 'exports-loader?Util!bootstrap/js/dist/util'
}),
new HtmlWebpackPlugin({
template: path.resolve(__dirname, './src', 'index.html'),
filename: path.resolve(__dirname, 'index.html'),
alwaysWriteToDisk: true
}),
new HtmlWebpackHarddiskPlugin()
],
resolve: {alias: {Services: path.resolve(__dirname, 'src/services/')}},
module: {
rules: [
{test: /\.css$/, use: ['style-loader', 'css-loader']},
{test: /\.scss$/, use: ['style-loader', 'css-loader', 'sass-loader']},
{test: /\.html$/, use: ['html-loader']},
{test: /src.*\.js$/, use: ['ng-annotate-loader']},
{test: /\.(png|jpg|jpeg|gif|ico)$/, loader: 'file-loader?name=[name].[ext]'},
{test: /\.(woff|woff2|ttf|eot|svg)(\?v=\d+\.\d+\.\d+)?$/, loader: 'file-loader'}
]
},
devServer: {
port: 8080,
proxy: {
'/api': {target: 'http://0.0.0.0:8000'},
'/exports': {target: 'http://0.0.0.0:8000'},
'/media': {target: 'http://0.0.0.0:8000'}
}
}
};
Karma.con.js
const webpack = require('webpack');
const webpackConfig = require('./webpack.config.js');
module.exports = function (config) {
config.set({
basePath: './',
frameworks: ['jasmine', 'mocha', 'chai'],
files: [
'./static/app.min.js',
'node_modules/angular-mocks/angular-mocks.js',
{pattern: 'test/foo.service.tests.js'}
],
preprocessors: {
'test/foo.service.tests.js': ['webpack']
},
webpack: {
module: webpackConfig.module,
plugins: webpackConfig.plugins
},
webpackMiddleware: {
stats: 'errors-only'
},
notifyReporter: {
reportEachFailure: true,
reportSuccess: false
},
plugins: [
'karma-phantomjs-launcher',
'karma-jasmine',
'karma-webpack',
'karma-mocha',
'karma-chai'
],
browsers: ['PhantomJS']
});
};
I'm running test coverage over my .js and .jsx files using karma, mocha, and isparta for ES6 code coverage.
For some reason the coverage report over .jsx files is corrupted.
See the following image:
The report looks the same for all of the .jsx files, i.e. from the line the JSX syntax appears - the coverage is corrupted, even though we can see the function has been visited once.
Here is my karma.conf.js file:
var path = require('path');
var isparta = require('isparta');
const babelOptions = {
presets: ['stage-0', 'react'],
plugins: [
'transform-es2015-modules-commonjs',
'transform-es2015-destructuring',
'transform-es2015-spread',
'transform-object-rest-spread',
'transform-class-properties'
]
};
module.exports = function (config) {
config.set({
browsers: [process.env.JENKINS_HOME ? 'Firefox' : 'Chrome'],
singleRun: true,
frameworks: ['mocha'],
files: [
'tests.webpack.js'
],
preprocessors: {
'tests.webpack.js': ['webpack', 'sourcemap'],
'src/**/*.jsx': ['coverage']
},
reporters: ['progress', 'coverage'],
coverageReporter: {
dir: 'dist/coverage/',
reporters: [
{type: 'html'},
{type: 'text-summary'}
],
includeAllSources: true,
instrumenters: {isparta: isparta},
instrumenter: {
'**/*.js': 'isparta',
'**/*.jsx': 'isparta'
},
instrumenterOptions: {
isparta: {
babel: babelOptions,
embedSource: true,
noAutoWrap: true,
}
}
},
webpack: {
babel: babelOptions,
devtool: 'inline-source-map',
resolve: {
root: [path.resolve('.')],
alias: {
i18nJson: 'nfvo-utils/i18n/locale.json',
'nfvo-utils/RestAPIUtil.js': 'test-utils/mocks/RestAPIUtil.js',
'nfvo-utils': 'src/nfvo-utils',
'nfvo-components': 'src/nfvo-components',
'sdc-app': 'src/sdc-app'
}
},
module: {
preLoaders: [
{test: /\.js$/, exclude: /(src|node_modules)/, loader: 'eslint-loader'},
{test: /\.(js|jsx)$/, exclude: /(test|test\.js|node_modules)/, loader: 'isparta'}
],
loaders: [
{test: /\.(js|jsx)$/, exclude: /node_modules/, loader: 'babel-loader'},
{test: /\.json$/, loaders: ['json']},
{test: /\.(css|scss|png|jpg|svg|ttf|eot|otf|woff|woff2)(\?.*)?$/, loader: 'ignore-loader'},
]
},
eslint: {
configFile: './.eslintrc',
emitError: true,
emitWarning: true
},
},
webpackServer: {
noInfo: true
}
});
};
Please let me know if any further information is required, and I'll edit.