0

What needs to be changed in below karma.config in order to resolve below error

 module.exports = function(config) {
config.set({
    basePath: '',
    frameworks: ['jasmine'],
    files: [
        
       // 'node_modules/@zxing/library/*.js'
       // 'assets/@zxing/library/esm/browser/BrowserMultiFormatReader.js'
       'assets/@zxing/library/*.js',
    ],

    exclude: [
        "assets/other.min.js"
    ],
    preprocessors: {
        'app/**/*.html': "ng-html2js",
        'app/views/**/!(*spec).js': ['coverage']
    },

    reporters: ['progress', 'html', 'coverage'],
    port: 3000,
    colors: true,
    autoWatch: true,
    browsers: ['Chrome'],
    singleRun: true,
    concurrency: Infinity,
    coverageReporter : {
      type : 'html',
      dir : 'coverage/',
      subdir: '.',
      check: {
            global: {
                ....,
                .....
            },
            each: {
               ....,
               ....
            }
        }
    },
    htmlReporter: {
        outputDir: 'karma_html',
        namedFiles: true, 
        reportName: 'sample_spec_report' 
    }
})

}

error

Chrome 85.0.4183 (Windows 10.0.0) ERROR
  Uncaught SyntaxError: Unexpected token 'export'
  at assets/@zxing/library/esm/browser.js:2

Chrome 85.0.4183 (Windows 10.0.0) ERROR
  Uncaught SyntaxError: Unexpected token 'export'
  at assets/@zxing/library/esm/browser.js:2

JavaScript Test Case Exit Code 1
JavaScript Test Case Fails

I'm, trying to make use of zxing.js in my Angular.1x app. MY CI/CD getting failed due to this error. library is working properly inside the app. im facing this issue the moment I use gulp karmaRunDebug. So need experts advice to resolve this. I'm struggling to fix this problem for past two.

I've no clue what needs to be done as am completely new setting up gulp and karma test environment.

zxing -> library

Thanks

Mr. Learner
  • 978
  • 2
  • 18
  • 48
  • 1
    I would suggest trying to use `@zxing/library/umd/index.min.js` instead of esm module(which looks to be not supported by your current configuration…) the other option would be to completely change the build configuration adding support for es modules and other more modern features… you can find an example here - https://github.com/zxbodya/angular-webpack-seed – Bogdan Savluk Oct 13 '20 at 14:17
  • Thanks alot @BogdanSavluk i've tried uninstalled / reinstalled node_modules and changed as per your first suggestion. Now the karma is running successfully – Mr. Learner Oct 14 '20 at 07:06

0 Answers0