rolaveric / karma-systemjs

Karma plugin for using SystemJS as a module loader
MIT License
40 stars 19 forks source link

v0.8.0+ fail to start karma #56

Closed kburson closed 9 years ago

kburson commented 9 years ago

If I upgrade to v0.8.1 or v0.8.2 I get the following error:

You need to include some adapter that implements __karma__.start method!

If I revert back to v0.8.0 the error goes away.

I am using Karma 0.13.14 with SystemJS 0.19.5

rolaveric commented 9 years ago

"implements" karma.start? That's a weird one.

The changes between v0.8.0 and v0.8.1 are to do with handling file patterns. One affects how includeFiles and serveFiles are interpreted: 820b421c1cd58f8bc05dbe295759d3b62bbeac83 The other is about handling /base' vs/absolute` paths from karma: 92bf6ff6d235e5521f22d6964b1bf295dfc1e8cc But if either of these had gone wrong I'd be expecting "0 of 0 tests run" error because your tests weren't picked up.

I'll have a play around with my projects to see if I can trigger it - update karma and systemjs to see if that triggers anything.

Any other info would be appreciated.

kburson commented 9 years ago

karma.conf.js

  module.exports = function (config) {
    config.set({
      port: 9876,
      urlRoot: '/',
      basePath: '_build/vertex', // project root
      proxies: {
        '/base/js/'             : '/base/_build/vertex/js/',
        //'/js'          : '/base/_build/vertex/js',
        '/base/client/src/app/' : '/base/_build/vertex/js/'
        //'/base/common': '/base/_build/vertex/js/components/common',
        //'/node_modules': '/base/node_modules'
        //'/jspm_packages': '/base/jspm_packages'
      },
      files : [
        //'client/src/app/**/*.spec.js',
        '../../client/src/app/components/common/services/apiHistory/apiHistory.service.spec.js'
      ],
      systemjs: {
        baseURL: '',
        configFile: 'js/system.config.js',
        //files: [],
        serveFiles: [
          'js/lib/*.map',
          'js/**/*.js',
          'mocks/**/*.json',
          'l10n/**/*.json'
        ],
        includeFiles: [],
        testFileSuffix: '.spec.js',
        config: {
          baseURL: '', //'/_build/vertex/js'
          transpiler: 'traceur',
          defaultJSExtensions: true,
          paths: {
            '/js/lib/*'           : 'js/lib/*',
            'vertex'              : 'js/components/vertex.js',
            //'es6-module-loader'   : '../../node_modules/es6-module-loader/dist/es6-module-loader.js',
            //'systemjs'            : '../../node_modules/systemjs/dist/system.js',
            //'system-polyfills'    : '../../node_modules/systemjs/dist/system-polyfills.js',
            //'traceur'             : '../../node_modules/traceur/bin/traceur.js'
            'es6-module-loader'   : 'js/lib/es6-module-loader.js',
            'systemjs'            : 'js/lib/system.js',
            'system-polyfills'    : 'js/lib/system-polyfills.js',
            'traceur'             : 'js/lib/traceur.js'
          }
        }
      },
      client: {
        mocha: {
          reporter: 'html',
          ui: 'bdd'
        },
      },
      plugins: ['karma-*'],
      frameworks: [ 'systemjs', 'mocha', 'chai'],
      browsers: [ 'Chrome'],
      captureTimeout: 10000,
      colors: true,
      reporters: [  'junit' , 'spec' , 'failed'  ],
      junitReporter: {
        outputDir: '_reports'
        ,outputFile: 'unit-test-results.xml' // default to $outputDir/$browserName/$outputFile
        ,suite: ''
        ,useBrowserName: true
      },
     });
  };
kburson commented 9 years ago

system.config.js

(function () {// all paths are relative to the location of index.html

// all paths are relative to baseURL
  var paths = {
    '*.css': '../../css/*.css',

    'lodash': './js/lib/lodash.js',
    'jquery': './js/lib/jquery.js',
    'moment': './js/lib/moment-with-locales.js',

    'angular': './js/lib/angular.js',
    'angular-animate': './js/lib/angular-animate.js',
    'angular-messages': './js/lib/angular-messages.js',
    'angular-aria': './js/lib/angular-aria.js',
    'angular-resource': './js/lib/angular-resource.js',
    'angular-cookies': './js/lib/angular-cookies.js',
    'angular-storage': './js/lib/angular-storage.js',
    'angular-material': './js/lib/angular-material.js',
    'angular-material-mocks': './js/lib/angular-material-mocks.js',
    'angular-sanitize': './js/lib/angular-sanitize.js',
    'angular-mocks': './js/lib/angular-mocks.js',
    'angular-logger': './js/lib/angular-logger.js',
    'angular-loading-bar': './js/lib/loading-bar.js',

    'angular-ui-router': './js/lib/angular-ui-router.js',
    'angular-dropdowns': './js/lib/angular-dropdowns.js',

    'angular-translate': './js/lib/angular-translate.js',
    'angular-translate-loader-static-files': './js/lib/angular-translate-loader-static-files.js',

    'spin': './js/lib/spin.js', //'./js/lib/spin.min.js',
    'angular-spinner': './js/lib/angular-spinner.js', //'./js/lib/angular-spinner.min.js',

    'pickadate': './js/lib/angular-pickadate.js',
    'ng-file-upload': './js/lib/ng-file-upload-all.js',

    'sprintf': './js/lib/sprintf.js',
    'json-patch': './js/lib/json-patch-duplex.min.js',

    'json': './js/lib/json.js',
    'text': './js/lib/text.js',
    'css': './js/lib/css.js',

    //'es6-module-loader': './js/lib/es6-module-loader.js',
    //'systemjs': './js/lib/system.js',
    //'system-polyfills': './js/lib/system-polyfills.js',
    //'traceur': './js/lib/traceur.js',

    'config.json': './config.json',
    'mocks/*.json': './mocks/*.json',
    'l10n/*': './l10n/*'
  };

  var minPaths = {
    'lodash': './js/lib/lodash.min.js',
    'jquery': './js/lib/jquery.min.js',
    'moment': './js/lib/moment-with-locales.min.js',

    'angular': './js/lib/angular.min.js',
    'angular-animate': './js/lib/angular-animate.min.js',
    'angular-messages': './js/lib/angular-messages.min.js',
    'angular-aria': './js/lib/angular-aria.min.js',
    'angular-resource': './js/lib/angular-resource.min.js',
    'angular-cookies': './js/lib/angular-cookies.min.js',
    'angular-storage': './js/lib/angular-storage.min.js',
    'angular-material': './js/lib/angular-material.min.js',
    'angular-sanitize': './js/lib/angular-sanitize.min.js',

    'angular-logger': './js/lib/angular-logger.min.js',
    'angular-loading-bar': './js/lib/loading-bar.min.js',
    'angular-ui-router': './js/lib/angular-ui-router.min.js',
    'angular-dropdowns': './js/lib/angular-dropdowns.min.js',

    'angular-translate': './js/lib/angular-translate.min.js',
    'angular-translate-loader-static-files': './js/lib/angular-translate-loader-static-files.min.js',

    'spin': './js/lib/spin.min.js', //'./js/lib/spin.min.js',
    'angular-spinner': './js/lib/angular-spinner.min.js', //'./js/lib/angular-spinner.min.js',

    'pickadate': './js/lib/angular-pickadate.min.js',
    'ng-file-upload': './js/lib/ng-file-upload-all.min.js',

    'json-patch': './js/lib/json-patch-duplex.min.js'
  };

  if (typeof window !== 'undefined') {
    if ('localhost' !== window.location.hostname) {
      for (var key in minPaths) {
        paths[key] = minPaths[key];
      }
    }
  }

// Identical to writing System.baseURL - ...
  System.config({
    baseURL: 'js/components/', //relative to index.html location
    defaultJSExtensions: true,
    paths: paths,

    // give hints for module dependencies
    meta: {
      'angular': {format: 'global', exports: 'angular'},
      'angular-animate': {format: 'global', deps: ['angular']},
      'angular-aria': {format: 'global', deps: ['angular']},
      'angular-cookies': {format: 'global', deps: ['angular']},
      'angular-material': {format: 'global', deps: ['angular', 'angular-messages', 'angular-aria', 'angular-animate']},
      'angular-messages': {format: 'global', deps: ['angular']},
      'angular-resource': {format: 'global', deps: ['angular']},

      'angular-mocks': {format: 'global', deps: ['angular']},

      'angular-ui-router': {format: 'global', deps: ['angular']},
      'angular-storage': {format: 'global', deps: ['angular']},
      'angular-dropdowns': {format: 'global', deps: ['angular']},

      'angular-translate': {format: 'global', deps: ['angular']},
      'angular-translate-loader-static-files': {format: 'global', deps: ['angular-translate']},

      'spin': {format: 'global'},
      'angular-spinner': {format: 'global', deps: ['angular', 'spin']},

      'pickadate': {format: 'global', deps: ['angular']},
      'ng-file-upload': {format: 'global', deps: ['angular']}
    },
    // create aliases
    // SystemJS Plugins, referenced with "moduleName!pluginName"
    map: {
      //'json': '/js/lib/json',
      //'text': '/js/lib/text'
    }
  });
})();
kburson commented 9 years ago

Project Layout

projectRoot/
   _build/
      vertex/
         css/
         fonts/
         img/
         js/
            components/
               common/
               home/
               verify/
                  leftNav/
                  request/
                  services/
                  toolbar/
               vertex.js
            lib/
               *.(js|map.js)
            mocks.js
            system.config.js
         l10n/
         mocks/
         .htaccess
         404.html
         config.json
         favicon.png
         index.html

   client/
      assets/
         css/
         fonts/
         img/
         l10n/
         mocks/
         .htaccess
         config.json
      src/
         app/
            components/
               common/
               home/
               verify/
                  leftNav/
                  request/
                  services/
                  toolbar
                  verify.js
               vertex.js
            404.html
            index.html
            system.config.js

   bower.json
   karma.conf.js
   package.json
   protractor.conf.js
rolaveric commented 9 years ago

Progress! I found how to replicate it: systemjs.includeFiles I don't fully understand what's happening yet, but just by having a systemjs.includeFiles array, even if it's empty, triggers the error. So good news: You can just comment out includeFiles in your karma config and you'll be good to go while I work on a fix.

kburson commented 9 years ago

thank you. My build is now fixed and I am running tests.