Skip to content

karma.error is not a function #157

@AStoker

Description

@AStoker

When I try and load up a module that has an incorrect path for an import, the promiseChain inside the karma-jspm/src/adapter fails (as it should). However, in the catch statement, on line 63, the call to karma.error is made, trying to error out a message. However, karma.error does not exist on the karma object, causing all the testing to shut down instead of failing on just that test.

Example test:

import PackageFactory from 'factories/InboxPackage';
describe('the test module', () => {
    it('is running tests', () => {
        expect(true).toBe(true);
    });
});

Error:

system.src.js:1085 GET http://localhost:9876/factories/InboxPackage.js 404 (Not Found)fetchTextFromURL @ system.src.js:1085(anonymous function) @ system.src.js:1646init @ system-polyfills.src.js:446Promise @ system-polyfills.src.js:434(anonymous function) @ system.src.js:1645(anonymous function) @ system.src.js:2667(anonymous function) @ system.src.js:3239(anonymous function) @ system.src.js:3506(anonymous function) @ system.src.js:3888(anonymous function) @ system.src.js:4347(anonymous function) @ system.src.js:4599(anonymous function) @ system.src.js:337tryCatchReject @ system-polyfills.src.js:1252runContinuation1 @ system-polyfills.src.js:1211Fulfilled.when @ system-polyfills.src.js:999Pending.run @ system-polyfills.src.js:890Scheduler._drain @ system-polyfills.src.js:166Scheduler.drain @ system-polyfills.src.js:131run @ system-polyfills.src.js:337
system-polyfills.src.js:209 Potentially unhandled rejection [4] TypeError: karma.error is not a function
    at http://localhost:9876/base/node_modules/karma-jspm/src/adapter.js:63:19
    at tryCatchReject (http://localhost:9876/base/wwwroot/jspm_packages/system-polyfills.src.js:1252:30)
    at runContinuation1 (http://localhost:9876/base/wwwroot/jspm_packages/system-polyfills.src.js:1211:4)
    at Rejected.when (http://localhost:9876/base/wwwroot/jspm_packages/system-polyfills.src.js:1032:4)
    at Pending.run (http://localhost:9876/base/wwwroot/jspm_packages/system-polyfills.src.js:890:13)
    at Scheduler._drain (http://localhost:9876/base/wwwroot/jspm_packages/system-polyfills.src.js:166:19)
    at Scheduler.drain (http://localhost:9876/base/wwwroot/jspm_packages/system-polyfills.src.js:131:9)
    at MutationObserver.run (http://localhost:9876/base/wwwroot/jspm_packages/system-polyfills.src.js:337:4)(anonymous function) @ system-polyfills.src.js:209report @ system-polyfills.src.js:236flush @ system-polyfills.src.js:258

Code that is failing:

//adapter.js: line 50
 // Load everything specified in loadFiles in the specified order
        var promiseChain = Promise.resolve();
        for (var i = 0; i < karma.config.jspm.expandedFiles.length; i++) {
            promiseChain = promiseChain.then((function (moduleName) {
                return function () {
                    return System['import'](moduleName);
                };
            })(extractModuleName(karma.config.jspm.expandedFiles[i])));
        }

        promiseChain.then(function () {
            karma.start();
        }, function (e) {
            karma.error(e.name + ": " + e.message); //  <--- This is the line that is causing the error.
        });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions