Karma Coverage failed to parse file and got Unexpected token error












0















Im using karma to test and report coverage of my project.
But i alway getting this error for all my js files:



  Failed to parse file: /home/.../src/services/Video/videoServices.js
22 11 2018 16:16:23.438:ERROR [preprocessor.coverage]: Line 1: Unexpected token
at /home/.../src/services/Video/videoServices.js


All unittest run normaly:



PhantomJS 2.1.1 (Linux 0.0.0): Executed 10 of 10 SUCCESS (0.07 secs / 0.058 secs)


But coverage allway be 100% 0/0. Look like karma can't parse my code so it can't render coverage.
enter image description here



here is my karma.config.js file:



/* eslint-env node, es6 */
const path = require('path');
const autoprefixer = require('autoprefixer');
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
const flexbugfixes = require('postcss-flexbugs-fixes');
const globalImport = require('postcss-global-import');
const LessPluginRi = require('resolution-independence');
const {DefinePlugin, EnvironmentPlugin} = require('webpack');
const {optionParser: app, EnzymeAdapterPlugin, GracefulFsPlugin, ILibPlugin} = require('@enact/dev-utils');

process.env.ES5 = 'true';

module.exports = function(karma) {
karma.set({
basePath: process.cwd(),
frameworks: ['mocha', 'chai', 'dirty-chai', 'jasmine'],
files: [
require.resolve('@babel/polyfill/dist/polyfill'),
require.resolve('mocha-react-proptype-checker'),
{pattern: 'src/**/*-specs.js', watched: true, serve: true, included: true},
{pattern: 'src/**/*.js', watched: true, serve: true, included: true}
],
reporters: ['progress', 'coverage'],
preprocessors: {
// add webpack as preprocessor
'./!(node_modules|dist|build)/**/*.js': ['webpack'],
[require.resolve('mocha-react-proptype-checker')]: ['webpack'],
'src/**/*.js': ['coverage']
},

failOnEmptyTestSuite: true,

webpack: {
// Use essentially the same webpack config as from the development build setup.
// We do not include an entry value as Karma will control that.
devtool: false,
output: {
path: './dist',
filename: '[name].js'
},
resolve: {
extensions: ['.js', '.jsx', '.json'],
modules: [
path.resolve(app.context, './node_modules'),
'node_modules',
],
alias: {
ilib: '@enact/i18n/ilib/lib',
'react-addons-test-utils': 'react-dom/test-utils'
}
},
externals: {
cheerio: 'window',
'react/addons': true,
'react/lib/ExecutionEnvironment': true,
'react/lib/ReactContext': true
},
target: app.environment,
node: Object.assign({}, app.nodeBuiltins || {}, {
console: true,
fs: 'empty',
net: 'empty',
tls: 'empty'
}),
module: {
rules: [
{
exclude: /.(html|js|jsx|css|less|ejs|json|txt)$/,
loader: require.resolve('file-loader'),
options: {name: '[path][name].[ext]'}
},
{
test: /.(html|txt)$/,
loader: require.resolve('raw-loader')
},
{
test: /.(js|jsx)$/,
exclude: /node_modules.(?!@enact)/,
loader: require.resolve('babel-loader'),
options: {
cacheDirectory: true,
// Generate a unique identifier string based off versons of components and app config.
cacheIdentifier: JSON.stringify({
'babel-loader': require('babel-loader/package.json').version,
'babel-core': require('@babel/core/package.json').version,
browsers: app.browsers,
node: app.node
})
}
},
{
test: /.(c|le)ss$/,
use: [
require.resolve('style-loader'),
{
loader: require.resolve('css-loader'),
options: {
importLoaders: 2,
modules: true,
localIdentName: '[name]__[local]___[hash:base64:5]'
}
},
{
loader: require.resolve('postcss-loader'),
options: {
ident: 'postcss',
plugins: () => [
autoprefixer({
browsers: app.browsers,
flexbox: 'no-2009',
remove: false
}),
flexbugfixes,
globalImport
]
}
},
{
loader: require.resolve('less-loader'),
options: {
modifyVars: Object.assign({}, app.accent),
plugins: app.ri ? [new LessPluginRi(app.ri)] :
}
}
]
}
],
noParse: /node_modules/json-schema/lib/validate.js/
},
devServer: {host: '0.0.0.0', port: 8080},
plugins: [
new DefinePlugin({'process.env.NODE_ENV': JSON.stringify('development')}),
new EnvironmentPlugin(Object.keys(process.env).filter(key => /^REACT_APP_/.test(key))),
new CaseSensitivePathsPlugin(),
new GracefulFsPlugin(),
new ILibPlugin({create: false}),
new EnzymeAdapterPlugin()
]
},
webpackServer: {
// please don't spam the console when running in karma!
noInfo: true,
progress: false,
stats: {
assets: false,
chunkModules: false,
chunks: false,
colors: true,
errorDetails: false,
hash: false,
reasons: false,
timings: false,
version: false,
children: false,
warnings: false,
moduleTrace: false
}
},
plugins: [
'karma-webpack',
'karma-mocha',
'karma-chai',
'karma-dirty-chai',
'karma-chrome-launcher',
'karma-phantomjs-launcher',
'karma-json-reporter',
'karma-jasmine-jquery',
'karma-jasmine',
'karma-coverage',
],
jsonReporter: {
stdout: true
},
client: {
mocha: {
timeout: 30000
}
},
port: 9876,
colors: true,
logLevel: karma.LOG_INFO,
browserNoActivityTimeout: 60000,
autoWatch: true,
browsers: ['PhantomJS'],
singleRun: false,
coverageReporter: {
includeAllSources: true,
dir: 'coverage/',
reporters: [
{ type: 'html', subdir: 'html' },
{ type: 'teamcity' },
]
},

});
};


and my package.json file :



{
"main": "src/index.js",
"scripts": {
"build": "webpack --config ./config/webpack.config.prod",
"pack": "node ./scripts/pack.js",
"pack-p": "node ./scripts/pack.js -p",
"serve": "webpack --config ./config/webpack.config.dev && node ./scripts/serve.js",
"watch": "node ./scripts/pack.js --watch",
"clean": "node ./scripts/clean.js",
"lint": "node ./scripts/lint.js .",
"license": "node ./scripts/license.js",
"test": "node ./scripts/test.js start --single-run",
"test-watch": "node ./scripts/test.js start"
},
"license": "Copyright (c) 2018 Framgia Inc",
"private": true,
"repository": "",
"enact": {
"theme": "moonstone"
},
"eslintIgnore": [
"node_modules/*",
"build/*",
"dist/*",
"config/*",
"scripts/*"
],
"eslintConfig": {
"extends": "enact"
},
"babel": {
"extends": "./config/.babelrc.js"
},
"dependencies": {
"@enact/cli": "^1.2.0",
"@enact/core": "^2.1.1",
"@enact/i18n": "^2.1.1",
"@enact/moonstone": "^2.1.1",
"@enact/spotlight": "^2.1.1",
"@enact/ui": "^2.1.1",
"@enact/webos": "^2.1.1",
"axios": "^0.18.0",
"i18next": "^11.6.0",
"kadira-storybook": "^1.38.3",
"lodash": "^4.17.10",
"moment": "^2.22.2",
"moment-duration-format": "^2.2.2",
"polished": "^1.9.3",
"prop-types": "^15.6.2",
"react": "^16.4.2",
"react-dom": "^16.4.2",
"react-inlinesvg": "^0.8.1",
"react-loadable": "^5.5.0",
"react-native-base64": "0.0.2",
"react-redux": "^5.0.7",
"react-router-dom": "^4.3.1",
"react-text-marquee": "^1.0.1",
"react-truncate": "^2.4.0",
"react-truncate-markup": "^2.0.1",
"reactstrap": "^6.4.0",
"redux": "^4.0.0",
"redux-actions": "^2.6.1",
"redux-logger": "^3.0.6",
"redux-saga": "^0.16.0",
"styled-components": "^3.4.2"
},
"devDependencies": {
"@babel/core": "7.0.0-beta.41",
"@babel/plugin-transform-react-inline-elements": "7.0.0-beta.41",
"@babel/plugin-transform-react-jsx-self": "7.0.0-beta.41",
"@babel/plugin-transform-react-jsx-source": "7.0.0-beta.41",
"@babel/polyfill": "7.0.0-beta.41",
"@babel/preset-env": "7.0.0-beta.41",
"@babel/preset-react": "7.0.0-beta.41",
"@babel/preset-stage-0": "7.0.0-beta.41",
"@enact/dev-utils": "1.1.1",
"@enact/template-moonstone": "1.0.0",
"autoprefixer": "8.1.0",
"babel-core": "^6.26.3",
"babel-eslint": "8.2.2",
"babel-loader": "8.0.0-beta.2",
"babel-plugin-dev-expression": "0.2.1",
"babel-plugin-transform-react-remove-prop-types": "^0.4.14",
"babel-preset-env": "^1.7.0",
"babel-preset-react": "^6.24.1",
"case-sensitive-paths-webpack-plugin": "2.1.2",
"chai": "3.5.0",
"chalk": "2.3.2",
"console-snoop": "0.1.1",
"cross-spawn": "6.0.5",
"css-loader": "0.28.10",
"dirty-chai": "2.0.1",
"enzyme": "3.3.0",
"enzyme-adapter-react-16": "1.1.1",
"eslint": "^5.3.0",
"eslint-config-airbnb": "^17.1.0",
"eslint-config-enact": "1.2.0",
"eslint-import-resolver-babel-module": "^4.0.0",
"eslint-loader": "1.9.0",
"eslint-plugin-babel": "4.1.2",
"eslint-plugin-enact": "0.1.3",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-jsx-a11y": "^6.1.1",
"eslint-plugin-react": "^7.10.0",
"expose-loader": "0.7.5",
"extract-text-webpack-plugin": "3.0.2",
"file-loader": "1.1.11",
"filesize": "3.6.0",
"fs-extra": "5.0.0",
"html-webpack-plugin": "2.30.1",
"istanbul": "^0.4.5",
"jest": "^23.6.0",
"karma": "^1.5.0",
"karma-babel-preprocessor": "8.0.0-beta.0",
"karma-chai": "0.1.0",
"karma-chrome-launcher": "2.2.0",
"karma-coverage": "^1.1.2",
"karma-dirty-chai": "2.0.0",
"karma-jasmine": "^2.0.1",
"karma-jasmine-jquery": "^0.1.1",
"karma-json-reporter": "1.2.1",
"karma-mocha": "1.3.0",
"karma-phantomjs-launcher": "1.0.4",
"karma-sourcemap-loader": "0.3.7",
"karma-webpack": "2.0.6",
"less": "3.0.1",
"less-loader": "4.1.0",
"license-checker": "16.0.0",
"minimist": "1.2.0",
"mocha": "5.0.4",
"mocha-react-proptype-checker": "0.1.0",
"phantomjs": "^2.1.7",
"postcss-flexbugs-fixes": "3.3.0",
"postcss-global-import": "1.0.6",
"postcss-loader": "2.1.1",
"postcss-remove-classes": "1.0.4",
"raw-loader": "1.0.0-beta.0",
"react-dev-utils": "5.0.0",
"react-test-renderer": "16.4.1",
"redux-mock-store": "^1.5.3",
"resolution-independence": "1.0.0",
"sinon": "4.4.6",
"strip-ansi": "4.0.0",
"style-loader": "0.20.3",
"thread-loader": "1.1.5",
"uglifyjs-webpack-plugin": "1.2.5",
"webpack": "3.11.0",
"webpack-dev-server": "2.11.1"
}
}


And my tree folder look like this:



-App
|-node_modules
|-src
| |- some_code.js
| |- tests
| | |-some_code-specs.js


I stuck with this issue for couple days, try to change karma config alot and find another coverage tool than karma-coverage but nothing work. Any one have an ideal for this problem? Thank you for your time.










share|improve this question



























    0















    Im using karma to test and report coverage of my project.
    But i alway getting this error for all my js files:



      Failed to parse file: /home/.../src/services/Video/videoServices.js
    22 11 2018 16:16:23.438:ERROR [preprocessor.coverage]: Line 1: Unexpected token
    at /home/.../src/services/Video/videoServices.js


    All unittest run normaly:



    PhantomJS 2.1.1 (Linux 0.0.0): Executed 10 of 10 SUCCESS (0.07 secs / 0.058 secs)


    But coverage allway be 100% 0/0. Look like karma can't parse my code so it can't render coverage.
    enter image description here



    here is my karma.config.js file:



    /* eslint-env node, es6 */
    const path = require('path');
    const autoprefixer = require('autoprefixer');
    const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
    const flexbugfixes = require('postcss-flexbugs-fixes');
    const globalImport = require('postcss-global-import');
    const LessPluginRi = require('resolution-independence');
    const {DefinePlugin, EnvironmentPlugin} = require('webpack');
    const {optionParser: app, EnzymeAdapterPlugin, GracefulFsPlugin, ILibPlugin} = require('@enact/dev-utils');

    process.env.ES5 = 'true';

    module.exports = function(karma) {
    karma.set({
    basePath: process.cwd(),
    frameworks: ['mocha', 'chai', 'dirty-chai', 'jasmine'],
    files: [
    require.resolve('@babel/polyfill/dist/polyfill'),
    require.resolve('mocha-react-proptype-checker'),
    {pattern: 'src/**/*-specs.js', watched: true, serve: true, included: true},
    {pattern: 'src/**/*.js', watched: true, serve: true, included: true}
    ],
    reporters: ['progress', 'coverage'],
    preprocessors: {
    // add webpack as preprocessor
    './!(node_modules|dist|build)/**/*.js': ['webpack'],
    [require.resolve('mocha-react-proptype-checker')]: ['webpack'],
    'src/**/*.js': ['coverage']
    },

    failOnEmptyTestSuite: true,

    webpack: {
    // Use essentially the same webpack config as from the development build setup.
    // We do not include an entry value as Karma will control that.
    devtool: false,
    output: {
    path: './dist',
    filename: '[name].js'
    },
    resolve: {
    extensions: ['.js', '.jsx', '.json'],
    modules: [
    path.resolve(app.context, './node_modules'),
    'node_modules',
    ],
    alias: {
    ilib: '@enact/i18n/ilib/lib',
    'react-addons-test-utils': 'react-dom/test-utils'
    }
    },
    externals: {
    cheerio: 'window',
    'react/addons': true,
    'react/lib/ExecutionEnvironment': true,
    'react/lib/ReactContext': true
    },
    target: app.environment,
    node: Object.assign({}, app.nodeBuiltins || {}, {
    console: true,
    fs: 'empty',
    net: 'empty',
    tls: 'empty'
    }),
    module: {
    rules: [
    {
    exclude: /.(html|js|jsx|css|less|ejs|json|txt)$/,
    loader: require.resolve('file-loader'),
    options: {name: '[path][name].[ext]'}
    },
    {
    test: /.(html|txt)$/,
    loader: require.resolve('raw-loader')
    },
    {
    test: /.(js|jsx)$/,
    exclude: /node_modules.(?!@enact)/,
    loader: require.resolve('babel-loader'),
    options: {
    cacheDirectory: true,
    // Generate a unique identifier string based off versons of components and app config.
    cacheIdentifier: JSON.stringify({
    'babel-loader': require('babel-loader/package.json').version,
    'babel-core': require('@babel/core/package.json').version,
    browsers: app.browsers,
    node: app.node
    })
    }
    },
    {
    test: /.(c|le)ss$/,
    use: [
    require.resolve('style-loader'),
    {
    loader: require.resolve('css-loader'),
    options: {
    importLoaders: 2,
    modules: true,
    localIdentName: '[name]__[local]___[hash:base64:5]'
    }
    },
    {
    loader: require.resolve('postcss-loader'),
    options: {
    ident: 'postcss',
    plugins: () => [
    autoprefixer({
    browsers: app.browsers,
    flexbox: 'no-2009',
    remove: false
    }),
    flexbugfixes,
    globalImport
    ]
    }
    },
    {
    loader: require.resolve('less-loader'),
    options: {
    modifyVars: Object.assign({}, app.accent),
    plugins: app.ri ? [new LessPluginRi(app.ri)] :
    }
    }
    ]
    }
    ],
    noParse: /node_modules/json-schema/lib/validate.js/
    },
    devServer: {host: '0.0.0.0', port: 8080},
    plugins: [
    new DefinePlugin({'process.env.NODE_ENV': JSON.stringify('development')}),
    new EnvironmentPlugin(Object.keys(process.env).filter(key => /^REACT_APP_/.test(key))),
    new CaseSensitivePathsPlugin(),
    new GracefulFsPlugin(),
    new ILibPlugin({create: false}),
    new EnzymeAdapterPlugin()
    ]
    },
    webpackServer: {
    // please don't spam the console when running in karma!
    noInfo: true,
    progress: false,
    stats: {
    assets: false,
    chunkModules: false,
    chunks: false,
    colors: true,
    errorDetails: false,
    hash: false,
    reasons: false,
    timings: false,
    version: false,
    children: false,
    warnings: false,
    moduleTrace: false
    }
    },
    plugins: [
    'karma-webpack',
    'karma-mocha',
    'karma-chai',
    'karma-dirty-chai',
    'karma-chrome-launcher',
    'karma-phantomjs-launcher',
    'karma-json-reporter',
    'karma-jasmine-jquery',
    'karma-jasmine',
    'karma-coverage',
    ],
    jsonReporter: {
    stdout: true
    },
    client: {
    mocha: {
    timeout: 30000
    }
    },
    port: 9876,
    colors: true,
    logLevel: karma.LOG_INFO,
    browserNoActivityTimeout: 60000,
    autoWatch: true,
    browsers: ['PhantomJS'],
    singleRun: false,
    coverageReporter: {
    includeAllSources: true,
    dir: 'coverage/',
    reporters: [
    { type: 'html', subdir: 'html' },
    { type: 'teamcity' },
    ]
    },

    });
    };


    and my package.json file :



    {
    "main": "src/index.js",
    "scripts": {
    "build": "webpack --config ./config/webpack.config.prod",
    "pack": "node ./scripts/pack.js",
    "pack-p": "node ./scripts/pack.js -p",
    "serve": "webpack --config ./config/webpack.config.dev && node ./scripts/serve.js",
    "watch": "node ./scripts/pack.js --watch",
    "clean": "node ./scripts/clean.js",
    "lint": "node ./scripts/lint.js .",
    "license": "node ./scripts/license.js",
    "test": "node ./scripts/test.js start --single-run",
    "test-watch": "node ./scripts/test.js start"
    },
    "license": "Copyright (c) 2018 Framgia Inc",
    "private": true,
    "repository": "",
    "enact": {
    "theme": "moonstone"
    },
    "eslintIgnore": [
    "node_modules/*",
    "build/*",
    "dist/*",
    "config/*",
    "scripts/*"
    ],
    "eslintConfig": {
    "extends": "enact"
    },
    "babel": {
    "extends": "./config/.babelrc.js"
    },
    "dependencies": {
    "@enact/cli": "^1.2.0",
    "@enact/core": "^2.1.1",
    "@enact/i18n": "^2.1.1",
    "@enact/moonstone": "^2.1.1",
    "@enact/spotlight": "^2.1.1",
    "@enact/ui": "^2.1.1",
    "@enact/webos": "^2.1.1",
    "axios": "^0.18.0",
    "i18next": "^11.6.0",
    "kadira-storybook": "^1.38.3",
    "lodash": "^4.17.10",
    "moment": "^2.22.2",
    "moment-duration-format": "^2.2.2",
    "polished": "^1.9.3",
    "prop-types": "^15.6.2",
    "react": "^16.4.2",
    "react-dom": "^16.4.2",
    "react-inlinesvg": "^0.8.1",
    "react-loadable": "^5.5.0",
    "react-native-base64": "0.0.2",
    "react-redux": "^5.0.7",
    "react-router-dom": "^4.3.1",
    "react-text-marquee": "^1.0.1",
    "react-truncate": "^2.4.0",
    "react-truncate-markup": "^2.0.1",
    "reactstrap": "^6.4.0",
    "redux": "^4.0.0",
    "redux-actions": "^2.6.1",
    "redux-logger": "^3.0.6",
    "redux-saga": "^0.16.0",
    "styled-components": "^3.4.2"
    },
    "devDependencies": {
    "@babel/core": "7.0.0-beta.41",
    "@babel/plugin-transform-react-inline-elements": "7.0.0-beta.41",
    "@babel/plugin-transform-react-jsx-self": "7.0.0-beta.41",
    "@babel/plugin-transform-react-jsx-source": "7.0.0-beta.41",
    "@babel/polyfill": "7.0.0-beta.41",
    "@babel/preset-env": "7.0.0-beta.41",
    "@babel/preset-react": "7.0.0-beta.41",
    "@babel/preset-stage-0": "7.0.0-beta.41",
    "@enact/dev-utils": "1.1.1",
    "@enact/template-moonstone": "1.0.0",
    "autoprefixer": "8.1.0",
    "babel-core": "^6.26.3",
    "babel-eslint": "8.2.2",
    "babel-loader": "8.0.0-beta.2",
    "babel-plugin-dev-expression": "0.2.1",
    "babel-plugin-transform-react-remove-prop-types": "^0.4.14",
    "babel-preset-env": "^1.7.0",
    "babel-preset-react": "^6.24.1",
    "case-sensitive-paths-webpack-plugin": "2.1.2",
    "chai": "3.5.0",
    "chalk": "2.3.2",
    "console-snoop": "0.1.1",
    "cross-spawn": "6.0.5",
    "css-loader": "0.28.10",
    "dirty-chai": "2.0.1",
    "enzyme": "3.3.0",
    "enzyme-adapter-react-16": "1.1.1",
    "eslint": "^5.3.0",
    "eslint-config-airbnb": "^17.1.0",
    "eslint-config-enact": "1.2.0",
    "eslint-import-resolver-babel-module": "^4.0.0",
    "eslint-loader": "1.9.0",
    "eslint-plugin-babel": "4.1.2",
    "eslint-plugin-enact": "0.1.3",
    "eslint-plugin-import": "^2.14.0",
    "eslint-plugin-jsx-a11y": "^6.1.1",
    "eslint-plugin-react": "^7.10.0",
    "expose-loader": "0.7.5",
    "extract-text-webpack-plugin": "3.0.2",
    "file-loader": "1.1.11",
    "filesize": "3.6.0",
    "fs-extra": "5.0.0",
    "html-webpack-plugin": "2.30.1",
    "istanbul": "^0.4.5",
    "jest": "^23.6.0",
    "karma": "^1.5.0",
    "karma-babel-preprocessor": "8.0.0-beta.0",
    "karma-chai": "0.1.0",
    "karma-chrome-launcher": "2.2.0",
    "karma-coverage": "^1.1.2",
    "karma-dirty-chai": "2.0.0",
    "karma-jasmine": "^2.0.1",
    "karma-jasmine-jquery": "^0.1.1",
    "karma-json-reporter": "1.2.1",
    "karma-mocha": "1.3.0",
    "karma-phantomjs-launcher": "1.0.4",
    "karma-sourcemap-loader": "0.3.7",
    "karma-webpack": "2.0.6",
    "less": "3.0.1",
    "less-loader": "4.1.0",
    "license-checker": "16.0.0",
    "minimist": "1.2.0",
    "mocha": "5.0.4",
    "mocha-react-proptype-checker": "0.1.0",
    "phantomjs": "^2.1.7",
    "postcss-flexbugs-fixes": "3.3.0",
    "postcss-global-import": "1.0.6",
    "postcss-loader": "2.1.1",
    "postcss-remove-classes": "1.0.4",
    "raw-loader": "1.0.0-beta.0",
    "react-dev-utils": "5.0.0",
    "react-test-renderer": "16.4.1",
    "redux-mock-store": "^1.5.3",
    "resolution-independence": "1.0.0",
    "sinon": "4.4.6",
    "strip-ansi": "4.0.0",
    "style-loader": "0.20.3",
    "thread-loader": "1.1.5",
    "uglifyjs-webpack-plugin": "1.2.5",
    "webpack": "3.11.0",
    "webpack-dev-server": "2.11.1"
    }
    }


    And my tree folder look like this:



    -App
    |-node_modules
    |-src
    | |- some_code.js
    | |- tests
    | | |-some_code-specs.js


    I stuck with this issue for couple days, try to change karma config alot and find another coverage tool than karma-coverage but nothing work. Any one have an ideal for this problem? Thank you for your time.










    share|improve this question

























      0












      0








      0








      Im using karma to test and report coverage of my project.
      But i alway getting this error for all my js files:



        Failed to parse file: /home/.../src/services/Video/videoServices.js
      22 11 2018 16:16:23.438:ERROR [preprocessor.coverage]: Line 1: Unexpected token
      at /home/.../src/services/Video/videoServices.js


      All unittest run normaly:



      PhantomJS 2.1.1 (Linux 0.0.0): Executed 10 of 10 SUCCESS (0.07 secs / 0.058 secs)


      But coverage allway be 100% 0/0. Look like karma can't parse my code so it can't render coverage.
      enter image description here



      here is my karma.config.js file:



      /* eslint-env node, es6 */
      const path = require('path');
      const autoprefixer = require('autoprefixer');
      const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
      const flexbugfixes = require('postcss-flexbugs-fixes');
      const globalImport = require('postcss-global-import');
      const LessPluginRi = require('resolution-independence');
      const {DefinePlugin, EnvironmentPlugin} = require('webpack');
      const {optionParser: app, EnzymeAdapterPlugin, GracefulFsPlugin, ILibPlugin} = require('@enact/dev-utils');

      process.env.ES5 = 'true';

      module.exports = function(karma) {
      karma.set({
      basePath: process.cwd(),
      frameworks: ['mocha', 'chai', 'dirty-chai', 'jasmine'],
      files: [
      require.resolve('@babel/polyfill/dist/polyfill'),
      require.resolve('mocha-react-proptype-checker'),
      {pattern: 'src/**/*-specs.js', watched: true, serve: true, included: true},
      {pattern: 'src/**/*.js', watched: true, serve: true, included: true}
      ],
      reporters: ['progress', 'coverage'],
      preprocessors: {
      // add webpack as preprocessor
      './!(node_modules|dist|build)/**/*.js': ['webpack'],
      [require.resolve('mocha-react-proptype-checker')]: ['webpack'],
      'src/**/*.js': ['coverage']
      },

      failOnEmptyTestSuite: true,

      webpack: {
      // Use essentially the same webpack config as from the development build setup.
      // We do not include an entry value as Karma will control that.
      devtool: false,
      output: {
      path: './dist',
      filename: '[name].js'
      },
      resolve: {
      extensions: ['.js', '.jsx', '.json'],
      modules: [
      path.resolve(app.context, './node_modules'),
      'node_modules',
      ],
      alias: {
      ilib: '@enact/i18n/ilib/lib',
      'react-addons-test-utils': 'react-dom/test-utils'
      }
      },
      externals: {
      cheerio: 'window',
      'react/addons': true,
      'react/lib/ExecutionEnvironment': true,
      'react/lib/ReactContext': true
      },
      target: app.environment,
      node: Object.assign({}, app.nodeBuiltins || {}, {
      console: true,
      fs: 'empty',
      net: 'empty',
      tls: 'empty'
      }),
      module: {
      rules: [
      {
      exclude: /.(html|js|jsx|css|less|ejs|json|txt)$/,
      loader: require.resolve('file-loader'),
      options: {name: '[path][name].[ext]'}
      },
      {
      test: /.(html|txt)$/,
      loader: require.resolve('raw-loader')
      },
      {
      test: /.(js|jsx)$/,
      exclude: /node_modules.(?!@enact)/,
      loader: require.resolve('babel-loader'),
      options: {
      cacheDirectory: true,
      // Generate a unique identifier string based off versons of components and app config.
      cacheIdentifier: JSON.stringify({
      'babel-loader': require('babel-loader/package.json').version,
      'babel-core': require('@babel/core/package.json').version,
      browsers: app.browsers,
      node: app.node
      })
      }
      },
      {
      test: /.(c|le)ss$/,
      use: [
      require.resolve('style-loader'),
      {
      loader: require.resolve('css-loader'),
      options: {
      importLoaders: 2,
      modules: true,
      localIdentName: '[name]__[local]___[hash:base64:5]'
      }
      },
      {
      loader: require.resolve('postcss-loader'),
      options: {
      ident: 'postcss',
      plugins: () => [
      autoprefixer({
      browsers: app.browsers,
      flexbox: 'no-2009',
      remove: false
      }),
      flexbugfixes,
      globalImport
      ]
      }
      },
      {
      loader: require.resolve('less-loader'),
      options: {
      modifyVars: Object.assign({}, app.accent),
      plugins: app.ri ? [new LessPluginRi(app.ri)] :
      }
      }
      ]
      }
      ],
      noParse: /node_modules/json-schema/lib/validate.js/
      },
      devServer: {host: '0.0.0.0', port: 8080},
      plugins: [
      new DefinePlugin({'process.env.NODE_ENV': JSON.stringify('development')}),
      new EnvironmentPlugin(Object.keys(process.env).filter(key => /^REACT_APP_/.test(key))),
      new CaseSensitivePathsPlugin(),
      new GracefulFsPlugin(),
      new ILibPlugin({create: false}),
      new EnzymeAdapterPlugin()
      ]
      },
      webpackServer: {
      // please don't spam the console when running in karma!
      noInfo: true,
      progress: false,
      stats: {
      assets: false,
      chunkModules: false,
      chunks: false,
      colors: true,
      errorDetails: false,
      hash: false,
      reasons: false,
      timings: false,
      version: false,
      children: false,
      warnings: false,
      moduleTrace: false
      }
      },
      plugins: [
      'karma-webpack',
      'karma-mocha',
      'karma-chai',
      'karma-dirty-chai',
      'karma-chrome-launcher',
      'karma-phantomjs-launcher',
      'karma-json-reporter',
      'karma-jasmine-jquery',
      'karma-jasmine',
      'karma-coverage',
      ],
      jsonReporter: {
      stdout: true
      },
      client: {
      mocha: {
      timeout: 30000
      }
      },
      port: 9876,
      colors: true,
      logLevel: karma.LOG_INFO,
      browserNoActivityTimeout: 60000,
      autoWatch: true,
      browsers: ['PhantomJS'],
      singleRun: false,
      coverageReporter: {
      includeAllSources: true,
      dir: 'coverage/',
      reporters: [
      { type: 'html', subdir: 'html' },
      { type: 'teamcity' },
      ]
      },

      });
      };


      and my package.json file :



      {
      "main": "src/index.js",
      "scripts": {
      "build": "webpack --config ./config/webpack.config.prod",
      "pack": "node ./scripts/pack.js",
      "pack-p": "node ./scripts/pack.js -p",
      "serve": "webpack --config ./config/webpack.config.dev && node ./scripts/serve.js",
      "watch": "node ./scripts/pack.js --watch",
      "clean": "node ./scripts/clean.js",
      "lint": "node ./scripts/lint.js .",
      "license": "node ./scripts/license.js",
      "test": "node ./scripts/test.js start --single-run",
      "test-watch": "node ./scripts/test.js start"
      },
      "license": "Copyright (c) 2018 Framgia Inc",
      "private": true,
      "repository": "",
      "enact": {
      "theme": "moonstone"
      },
      "eslintIgnore": [
      "node_modules/*",
      "build/*",
      "dist/*",
      "config/*",
      "scripts/*"
      ],
      "eslintConfig": {
      "extends": "enact"
      },
      "babel": {
      "extends": "./config/.babelrc.js"
      },
      "dependencies": {
      "@enact/cli": "^1.2.0",
      "@enact/core": "^2.1.1",
      "@enact/i18n": "^2.1.1",
      "@enact/moonstone": "^2.1.1",
      "@enact/spotlight": "^2.1.1",
      "@enact/ui": "^2.1.1",
      "@enact/webos": "^2.1.1",
      "axios": "^0.18.0",
      "i18next": "^11.6.0",
      "kadira-storybook": "^1.38.3",
      "lodash": "^4.17.10",
      "moment": "^2.22.2",
      "moment-duration-format": "^2.2.2",
      "polished": "^1.9.3",
      "prop-types": "^15.6.2",
      "react": "^16.4.2",
      "react-dom": "^16.4.2",
      "react-inlinesvg": "^0.8.1",
      "react-loadable": "^5.5.0",
      "react-native-base64": "0.0.2",
      "react-redux": "^5.0.7",
      "react-router-dom": "^4.3.1",
      "react-text-marquee": "^1.0.1",
      "react-truncate": "^2.4.0",
      "react-truncate-markup": "^2.0.1",
      "reactstrap": "^6.4.0",
      "redux": "^4.0.0",
      "redux-actions": "^2.6.1",
      "redux-logger": "^3.0.6",
      "redux-saga": "^0.16.0",
      "styled-components": "^3.4.2"
      },
      "devDependencies": {
      "@babel/core": "7.0.0-beta.41",
      "@babel/plugin-transform-react-inline-elements": "7.0.0-beta.41",
      "@babel/plugin-transform-react-jsx-self": "7.0.0-beta.41",
      "@babel/plugin-transform-react-jsx-source": "7.0.0-beta.41",
      "@babel/polyfill": "7.0.0-beta.41",
      "@babel/preset-env": "7.0.0-beta.41",
      "@babel/preset-react": "7.0.0-beta.41",
      "@babel/preset-stage-0": "7.0.0-beta.41",
      "@enact/dev-utils": "1.1.1",
      "@enact/template-moonstone": "1.0.0",
      "autoprefixer": "8.1.0",
      "babel-core": "^6.26.3",
      "babel-eslint": "8.2.2",
      "babel-loader": "8.0.0-beta.2",
      "babel-plugin-dev-expression": "0.2.1",
      "babel-plugin-transform-react-remove-prop-types": "^0.4.14",
      "babel-preset-env": "^1.7.0",
      "babel-preset-react": "^6.24.1",
      "case-sensitive-paths-webpack-plugin": "2.1.2",
      "chai": "3.5.0",
      "chalk": "2.3.2",
      "console-snoop": "0.1.1",
      "cross-spawn": "6.0.5",
      "css-loader": "0.28.10",
      "dirty-chai": "2.0.1",
      "enzyme": "3.3.0",
      "enzyme-adapter-react-16": "1.1.1",
      "eslint": "^5.3.0",
      "eslint-config-airbnb": "^17.1.0",
      "eslint-config-enact": "1.2.0",
      "eslint-import-resolver-babel-module": "^4.0.0",
      "eslint-loader": "1.9.0",
      "eslint-plugin-babel": "4.1.2",
      "eslint-plugin-enact": "0.1.3",
      "eslint-plugin-import": "^2.14.0",
      "eslint-plugin-jsx-a11y": "^6.1.1",
      "eslint-plugin-react": "^7.10.0",
      "expose-loader": "0.7.5",
      "extract-text-webpack-plugin": "3.0.2",
      "file-loader": "1.1.11",
      "filesize": "3.6.0",
      "fs-extra": "5.0.0",
      "html-webpack-plugin": "2.30.1",
      "istanbul": "^0.4.5",
      "jest": "^23.6.0",
      "karma": "^1.5.0",
      "karma-babel-preprocessor": "8.0.0-beta.0",
      "karma-chai": "0.1.0",
      "karma-chrome-launcher": "2.2.0",
      "karma-coverage": "^1.1.2",
      "karma-dirty-chai": "2.0.0",
      "karma-jasmine": "^2.0.1",
      "karma-jasmine-jquery": "^0.1.1",
      "karma-json-reporter": "1.2.1",
      "karma-mocha": "1.3.0",
      "karma-phantomjs-launcher": "1.0.4",
      "karma-sourcemap-loader": "0.3.7",
      "karma-webpack": "2.0.6",
      "less": "3.0.1",
      "less-loader": "4.1.0",
      "license-checker": "16.0.0",
      "minimist": "1.2.0",
      "mocha": "5.0.4",
      "mocha-react-proptype-checker": "0.1.0",
      "phantomjs": "^2.1.7",
      "postcss-flexbugs-fixes": "3.3.0",
      "postcss-global-import": "1.0.6",
      "postcss-loader": "2.1.1",
      "postcss-remove-classes": "1.0.4",
      "raw-loader": "1.0.0-beta.0",
      "react-dev-utils": "5.0.0",
      "react-test-renderer": "16.4.1",
      "redux-mock-store": "^1.5.3",
      "resolution-independence": "1.0.0",
      "sinon": "4.4.6",
      "strip-ansi": "4.0.0",
      "style-loader": "0.20.3",
      "thread-loader": "1.1.5",
      "uglifyjs-webpack-plugin": "1.2.5",
      "webpack": "3.11.0",
      "webpack-dev-server": "2.11.1"
      }
      }


      And my tree folder look like this:



      -App
      |-node_modules
      |-src
      | |- some_code.js
      | |- tests
      | | |-some_code-specs.js


      I stuck with this issue for couple days, try to change karma config alot and find another coverage tool than karma-coverage but nothing work. Any one have an ideal for this problem? Thank you for your time.










      share|improve this question














      Im using karma to test and report coverage of my project.
      But i alway getting this error for all my js files:



        Failed to parse file: /home/.../src/services/Video/videoServices.js
      22 11 2018 16:16:23.438:ERROR [preprocessor.coverage]: Line 1: Unexpected token
      at /home/.../src/services/Video/videoServices.js


      All unittest run normaly:



      PhantomJS 2.1.1 (Linux 0.0.0): Executed 10 of 10 SUCCESS (0.07 secs / 0.058 secs)


      But coverage allway be 100% 0/0. Look like karma can't parse my code so it can't render coverage.
      enter image description here



      here is my karma.config.js file:



      /* eslint-env node, es6 */
      const path = require('path');
      const autoprefixer = require('autoprefixer');
      const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
      const flexbugfixes = require('postcss-flexbugs-fixes');
      const globalImport = require('postcss-global-import');
      const LessPluginRi = require('resolution-independence');
      const {DefinePlugin, EnvironmentPlugin} = require('webpack');
      const {optionParser: app, EnzymeAdapterPlugin, GracefulFsPlugin, ILibPlugin} = require('@enact/dev-utils');

      process.env.ES5 = 'true';

      module.exports = function(karma) {
      karma.set({
      basePath: process.cwd(),
      frameworks: ['mocha', 'chai', 'dirty-chai', 'jasmine'],
      files: [
      require.resolve('@babel/polyfill/dist/polyfill'),
      require.resolve('mocha-react-proptype-checker'),
      {pattern: 'src/**/*-specs.js', watched: true, serve: true, included: true},
      {pattern: 'src/**/*.js', watched: true, serve: true, included: true}
      ],
      reporters: ['progress', 'coverage'],
      preprocessors: {
      // add webpack as preprocessor
      './!(node_modules|dist|build)/**/*.js': ['webpack'],
      [require.resolve('mocha-react-proptype-checker')]: ['webpack'],
      'src/**/*.js': ['coverage']
      },

      failOnEmptyTestSuite: true,

      webpack: {
      // Use essentially the same webpack config as from the development build setup.
      // We do not include an entry value as Karma will control that.
      devtool: false,
      output: {
      path: './dist',
      filename: '[name].js'
      },
      resolve: {
      extensions: ['.js', '.jsx', '.json'],
      modules: [
      path.resolve(app.context, './node_modules'),
      'node_modules',
      ],
      alias: {
      ilib: '@enact/i18n/ilib/lib',
      'react-addons-test-utils': 'react-dom/test-utils'
      }
      },
      externals: {
      cheerio: 'window',
      'react/addons': true,
      'react/lib/ExecutionEnvironment': true,
      'react/lib/ReactContext': true
      },
      target: app.environment,
      node: Object.assign({}, app.nodeBuiltins || {}, {
      console: true,
      fs: 'empty',
      net: 'empty',
      tls: 'empty'
      }),
      module: {
      rules: [
      {
      exclude: /.(html|js|jsx|css|less|ejs|json|txt)$/,
      loader: require.resolve('file-loader'),
      options: {name: '[path][name].[ext]'}
      },
      {
      test: /.(html|txt)$/,
      loader: require.resolve('raw-loader')
      },
      {
      test: /.(js|jsx)$/,
      exclude: /node_modules.(?!@enact)/,
      loader: require.resolve('babel-loader'),
      options: {
      cacheDirectory: true,
      // Generate a unique identifier string based off versons of components and app config.
      cacheIdentifier: JSON.stringify({
      'babel-loader': require('babel-loader/package.json').version,
      'babel-core': require('@babel/core/package.json').version,
      browsers: app.browsers,
      node: app.node
      })
      }
      },
      {
      test: /.(c|le)ss$/,
      use: [
      require.resolve('style-loader'),
      {
      loader: require.resolve('css-loader'),
      options: {
      importLoaders: 2,
      modules: true,
      localIdentName: '[name]__[local]___[hash:base64:5]'
      }
      },
      {
      loader: require.resolve('postcss-loader'),
      options: {
      ident: 'postcss',
      plugins: () => [
      autoprefixer({
      browsers: app.browsers,
      flexbox: 'no-2009',
      remove: false
      }),
      flexbugfixes,
      globalImport
      ]
      }
      },
      {
      loader: require.resolve('less-loader'),
      options: {
      modifyVars: Object.assign({}, app.accent),
      plugins: app.ri ? [new LessPluginRi(app.ri)] :
      }
      }
      ]
      }
      ],
      noParse: /node_modules/json-schema/lib/validate.js/
      },
      devServer: {host: '0.0.0.0', port: 8080},
      plugins: [
      new DefinePlugin({'process.env.NODE_ENV': JSON.stringify('development')}),
      new EnvironmentPlugin(Object.keys(process.env).filter(key => /^REACT_APP_/.test(key))),
      new CaseSensitivePathsPlugin(),
      new GracefulFsPlugin(),
      new ILibPlugin({create: false}),
      new EnzymeAdapterPlugin()
      ]
      },
      webpackServer: {
      // please don't spam the console when running in karma!
      noInfo: true,
      progress: false,
      stats: {
      assets: false,
      chunkModules: false,
      chunks: false,
      colors: true,
      errorDetails: false,
      hash: false,
      reasons: false,
      timings: false,
      version: false,
      children: false,
      warnings: false,
      moduleTrace: false
      }
      },
      plugins: [
      'karma-webpack',
      'karma-mocha',
      'karma-chai',
      'karma-dirty-chai',
      'karma-chrome-launcher',
      'karma-phantomjs-launcher',
      'karma-json-reporter',
      'karma-jasmine-jquery',
      'karma-jasmine',
      'karma-coverage',
      ],
      jsonReporter: {
      stdout: true
      },
      client: {
      mocha: {
      timeout: 30000
      }
      },
      port: 9876,
      colors: true,
      logLevel: karma.LOG_INFO,
      browserNoActivityTimeout: 60000,
      autoWatch: true,
      browsers: ['PhantomJS'],
      singleRun: false,
      coverageReporter: {
      includeAllSources: true,
      dir: 'coverage/',
      reporters: [
      { type: 'html', subdir: 'html' },
      { type: 'teamcity' },
      ]
      },

      });
      };


      and my package.json file :



      {
      "main": "src/index.js",
      "scripts": {
      "build": "webpack --config ./config/webpack.config.prod",
      "pack": "node ./scripts/pack.js",
      "pack-p": "node ./scripts/pack.js -p",
      "serve": "webpack --config ./config/webpack.config.dev && node ./scripts/serve.js",
      "watch": "node ./scripts/pack.js --watch",
      "clean": "node ./scripts/clean.js",
      "lint": "node ./scripts/lint.js .",
      "license": "node ./scripts/license.js",
      "test": "node ./scripts/test.js start --single-run",
      "test-watch": "node ./scripts/test.js start"
      },
      "license": "Copyright (c) 2018 Framgia Inc",
      "private": true,
      "repository": "",
      "enact": {
      "theme": "moonstone"
      },
      "eslintIgnore": [
      "node_modules/*",
      "build/*",
      "dist/*",
      "config/*",
      "scripts/*"
      ],
      "eslintConfig": {
      "extends": "enact"
      },
      "babel": {
      "extends": "./config/.babelrc.js"
      },
      "dependencies": {
      "@enact/cli": "^1.2.0",
      "@enact/core": "^2.1.1",
      "@enact/i18n": "^2.1.1",
      "@enact/moonstone": "^2.1.1",
      "@enact/spotlight": "^2.1.1",
      "@enact/ui": "^2.1.1",
      "@enact/webos": "^2.1.1",
      "axios": "^0.18.0",
      "i18next": "^11.6.0",
      "kadira-storybook": "^1.38.3",
      "lodash": "^4.17.10",
      "moment": "^2.22.2",
      "moment-duration-format": "^2.2.2",
      "polished": "^1.9.3",
      "prop-types": "^15.6.2",
      "react": "^16.4.2",
      "react-dom": "^16.4.2",
      "react-inlinesvg": "^0.8.1",
      "react-loadable": "^5.5.0",
      "react-native-base64": "0.0.2",
      "react-redux": "^5.0.7",
      "react-router-dom": "^4.3.1",
      "react-text-marquee": "^1.0.1",
      "react-truncate": "^2.4.0",
      "react-truncate-markup": "^2.0.1",
      "reactstrap": "^6.4.0",
      "redux": "^4.0.0",
      "redux-actions": "^2.6.1",
      "redux-logger": "^3.0.6",
      "redux-saga": "^0.16.0",
      "styled-components": "^3.4.2"
      },
      "devDependencies": {
      "@babel/core": "7.0.0-beta.41",
      "@babel/plugin-transform-react-inline-elements": "7.0.0-beta.41",
      "@babel/plugin-transform-react-jsx-self": "7.0.0-beta.41",
      "@babel/plugin-transform-react-jsx-source": "7.0.0-beta.41",
      "@babel/polyfill": "7.0.0-beta.41",
      "@babel/preset-env": "7.0.0-beta.41",
      "@babel/preset-react": "7.0.0-beta.41",
      "@babel/preset-stage-0": "7.0.0-beta.41",
      "@enact/dev-utils": "1.1.1",
      "@enact/template-moonstone": "1.0.0",
      "autoprefixer": "8.1.0",
      "babel-core": "^6.26.3",
      "babel-eslint": "8.2.2",
      "babel-loader": "8.0.0-beta.2",
      "babel-plugin-dev-expression": "0.2.1",
      "babel-plugin-transform-react-remove-prop-types": "^0.4.14",
      "babel-preset-env": "^1.7.0",
      "babel-preset-react": "^6.24.1",
      "case-sensitive-paths-webpack-plugin": "2.1.2",
      "chai": "3.5.0",
      "chalk": "2.3.2",
      "console-snoop": "0.1.1",
      "cross-spawn": "6.0.5",
      "css-loader": "0.28.10",
      "dirty-chai": "2.0.1",
      "enzyme": "3.3.0",
      "enzyme-adapter-react-16": "1.1.1",
      "eslint": "^5.3.0",
      "eslint-config-airbnb": "^17.1.0",
      "eslint-config-enact": "1.2.0",
      "eslint-import-resolver-babel-module": "^4.0.0",
      "eslint-loader": "1.9.0",
      "eslint-plugin-babel": "4.1.2",
      "eslint-plugin-enact": "0.1.3",
      "eslint-plugin-import": "^2.14.0",
      "eslint-plugin-jsx-a11y": "^6.1.1",
      "eslint-plugin-react": "^7.10.0",
      "expose-loader": "0.7.5",
      "extract-text-webpack-plugin": "3.0.2",
      "file-loader": "1.1.11",
      "filesize": "3.6.0",
      "fs-extra": "5.0.0",
      "html-webpack-plugin": "2.30.1",
      "istanbul": "^0.4.5",
      "jest": "^23.6.0",
      "karma": "^1.5.0",
      "karma-babel-preprocessor": "8.0.0-beta.0",
      "karma-chai": "0.1.0",
      "karma-chrome-launcher": "2.2.0",
      "karma-coverage": "^1.1.2",
      "karma-dirty-chai": "2.0.0",
      "karma-jasmine": "^2.0.1",
      "karma-jasmine-jquery": "^0.1.1",
      "karma-json-reporter": "1.2.1",
      "karma-mocha": "1.3.0",
      "karma-phantomjs-launcher": "1.0.4",
      "karma-sourcemap-loader": "0.3.7",
      "karma-webpack": "2.0.6",
      "less": "3.0.1",
      "less-loader": "4.1.0",
      "license-checker": "16.0.0",
      "minimist": "1.2.0",
      "mocha": "5.0.4",
      "mocha-react-proptype-checker": "0.1.0",
      "phantomjs": "^2.1.7",
      "postcss-flexbugs-fixes": "3.3.0",
      "postcss-global-import": "1.0.6",
      "postcss-loader": "2.1.1",
      "postcss-remove-classes": "1.0.4",
      "raw-loader": "1.0.0-beta.0",
      "react-dev-utils": "5.0.0",
      "react-test-renderer": "16.4.1",
      "redux-mock-store": "^1.5.3",
      "resolution-independence": "1.0.0",
      "sinon": "4.4.6",
      "strip-ansi": "4.0.0",
      "style-loader": "0.20.3",
      "thread-loader": "1.1.5",
      "uglifyjs-webpack-plugin": "1.2.5",
      "webpack": "3.11.0",
      "webpack-dev-server": "2.11.1"
      }
      }


      And my tree folder look like this:



      -App
      |-node_modules
      |-src
      | |- some_code.js
      | |- tests
      | | |-some_code-specs.js


      I stuck with this issue for couple days, try to change karma config alot and find another coverage tool than karma-coverage but nothing work. Any one have an ideal for this problem? Thank you for your time.







      karma-jasmine karma-coverage






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 22 '18 at 9:14









      Long LýLong Lý

      2419




      2419
























          0






          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53427412%2fkarma-coverage-failed-to-parse-file-and-got-unexpected-token-error%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53427412%2fkarma-coverage-failed-to-parse-file-and-got-unexpected-token-error%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Costa Masnaga

          Fotorealismo

          Sidney Franklin