computmaxer / karma-jspm

Other
74 stars 50 forks source link

Can't find variable when using jspm #138

Open micaelmbagira opened 8 years ago

micaelmbagira commented 8 years ago

I'm using jspm to load angular, when I run karma, I have Can't find variable: angular. This error is generated by the file generated by ng-html2js. Here is my karma.conf :

module.exports = function (config) {
  const configuration = {
    browsers: [
      'PhantomJS'
    ],
    basePath: '../',
    singleRun: true,
    autoWatch: false,
    logLevel: 'INFO',
    junitReporter: {
      outputDir: 'test-reports'
    },
    frameworks: [
      'phantomjs-shim',
      'jspm',
      'jasmine'
    ],
    preprocessors: {
      [conf.path.src('**/*.html')]: [
        'ng-html2js'
      ]
    },
    ngHtml2JsPreprocessor: {},
    jspm: {
      config: 'jspm.config.js',
      loadFiles: [
        conf.path.src('app/**/*.js'),
        conf.path.src('**/*.html')
      ]
    },
    plugins: [
      require('karma-jasmine'),
      require('karma-junit-reporter'),
      require('karma-phantomjs-launcher'),
      require('karma-phantomjs-shim'),
      require('karma-coverage'),
      require('karma-ng-html2js-preprocessor'),
      require('karma-jspm')
    ]
  };

  config.set(configuration);
};

I tried to add angular to the paths lists and also to the files list but none worked.

micaelmbagira commented 8 years ago

Actually I have this error when I add base/ prefix before conf.path.src('app/**/*.js'), in jspm.loadFiles. When I don't add this, I have the following error : Potentially unhandled rejection [6] Error: XHR error (404 Not Found) loading http://localhost:9876/base/jspm_packages/npm/systemjs-plugin-babel@0.0.8