computmaxer / karma-jspm

Other
74 stars 50 forks source link

karma.loaded issue; SystemJS configurations "separated"; Multiple strippable file extensions #172

Closed RobinBuschmann closed 6 years ago

RobinBuschmann commented 8 years ago

karma.loaded issue

I've made the experience, that some other plugins also override the karma.loaded method. In my case the sinon-chai plugin for karma. This leads to the problem, that the referred function of karma-jspm never get called and the tests never get executed. To prevent this, the karma-jspm plugin now throws an error if any other plugin trys to override "loaded":

Object.defineProperty(karma, 'loaded', {
     set: function () {
            if(karma.config.jspm.ignoreOverrideError) return;

            throw new Error('karma.loaded was already overridden by karma-jspm. ' +
                'karma-jspm is not compatible with other plugins, which also overrides karma.loaded. ' 
                'You can set "ignoreOverrideError" true in karma.conf.js, if you want to ignore this error.');
      },
      get: function () {
            return loaded
      }
});

function loaded() { ... }

To be honestly, I have no clue, if overriding "loaded" is a good idea anyway. Unfortunetely karma provides no documentation to write own plugins. They only refer to existing ones. Maybe someone else can clear this?

SystemJS configurations "separated"

For my project it was necessary to override more than the paths property of the system js configuration. That's why I would like to give the consumer of this plugin the possibility to override what ever she wants regarding the system js configuration:

jspm: {
    systemJs: {
        baseURL: 'base/src',
        paths: {
          ...
        },
        ...
    }
}

Multiple file extensions that could be removed

In my project it was also necessary to strip the file extension of typescript files. So I removed the stripExtension option and replaced it with extensionsToStrip:

jspm: {
    extensionsToStrip: ['ts', 'js']
}
aviary2-wf commented 8 years ago

Raven

Number of Findings: 0