2

I am writing angular 2 unit tests (Karma) and I am using the PrimeNG library for some angular 2 components in my code. I referenced the library as follows : {pattern: 'dist/lib/primeng/primeng.js', included: true, watched: true},

Then I got the "require is not defined" problem.

I installed "browserify" as seen : here.

karma.conf.js

frameworks: ['jasmine', 'browserify'],

files: [
  // paths loaded by Karma
  {pattern: 'node_modules/systemjs/dist/system-polyfills.js', included: true, watched: true},
  {pattern: 'node_modules/systemjs/dist/system.src.js', included: true, watched: true},
  {pattern: 'node_modules/es6-shim/es6-shim.js', included: true, watched: true},
  {pattern: 'node_modules/angular2/bundles/angular2-polyfills.js', included: true, watched: true},
  {pattern: 'node_modules/rxjs/bundles/Rx.js', included: true, watched: true},
  {pattern: 'node_modules/angular2/bundles/angular2.js', included: true, watched: true},
  {pattern: 'node_modules/angular2/bundles/testing.dev.js', included: true, watched: true},
  {pattern: 'node_modules/angular2/bundles/router.dev.js', included: true, watched: true},
  {pattern: 'node_modules/ng2-translate/bundles/ng2-translate.js', included: true, watched: true},
  {pattern: 'node_modules/angular2/bundles/http.dev.js', included: true, watched: true},
  {pattern: 'node_modules/angular2/testing_internal/bundles/angular2.js', included: true, watched: true},
  {pattern: 'dist/lib/primeng/primeng.js', included: true, watched: true},

...

preprocessors: {
  'dist/**/!(*spec).js': ['coverage', 'browserify']
},

...

Now I get the error: Uncaught Error: bundle error (see logs) 85fde0323d1ffadfffe8f4c4080d0f13.browserify

I understand the error is because I didn't do the steps mentioned here, but even if that would work I don't think I got the whole picture. I do not want to build the bundle manually each time when you install stuff or when you pull from repository

Community
  • 1
  • 1
ng-flo
  • 293
  • 4
  • 17

0 Answers0