Настройка модульного теста Karma/Jasmine с JSPM 404 на SystemJS

Я пытаюсь заставить Karma/Babel/Jasmine/Aurelia работать вместе, однако я получаю эту ошибку при запуске karma start

Chrome 50.0.2661 (Windows 10 0.0.0) ERROR
SystemJS was not found. Please make sure you have initialized jspm via installing a dependency with jspm, or by running 'jspm dl-loader'.

Файл system.js находится в папке lib.

Моя структура папок:

> Web
  karma.conf.js
  -> node_modules
  -> lib (systemjs is located here)
  -> js
     config.js
     --> ** (I will have more than one unit test folder but they will all be located at this level.  All my js will be located here as well.)
         --> Test
             --> Unit

Моя карма.conf.js

// Karma configuration
// Generated on Fri Dec 05 2014 16:49:29 GMT-0500 (EST)

module.exports = function (config) {
    config.set({

        // base path that will be used to resolve all patterns (eg. files, exclude)
        basePath: '../',

        // frameworks to use
        // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
        frameworks: ['jspm', 'jasmine'],

        jspm: {
            // Edit this to your needs
            loadFiles: ['js/**/Test/Unit/setup.js', 'js/**/Test/Unit/**/*.js'],
            serveFiles: ['js/**/*.js'],
            paths: {
                'github:*': 'lib/github/*',
                'npm:*': 'lib/npm/*',
                'lib/*': 'lib/*',
                'kendo.*': 'lib/kendoui/js/kendo.*.js',
                'kendo-ui/*': 'lib/kendoui/*',
                'sqlsentry/*': 'lib/SqlSentry/*'
            }
        },

        // list of files / patterns to load in the browser
        files: [],

        // list of files to exclude
        exclude: [],


        // preprocess matching files before serving them to the browser
        // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
        //preprocessors: {
        //    'test/**/*.js': ['babel'],
        //    'src/**/*.js': ['babel']
        //},
        //'babelPreprocessor': {
        //    options: {
        //        sourceMap: 'inline',
        //        presets: ['es2015-loose', 'stage-1'],
        //        plugins: [
        //            'syntax-flow',
        //            'transform-decorators-legacy',
        //           'transform-flow-strip-types'
        //        ]
        //    }
        //},

        // test results reporter to use
        // possible values: 'dots', 'progress'
        // available reporters: https://npmjs.org/browse/keyword/karma-reporter
        reporters: ['progress'],

        // web server port
        port: 9876,

        // enable / disable colors in the output (reporters and logs)
        colors: true,

        // level of logging
        // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
        logLevel: config.LOG_DEBUG,

        // enable / disable watching file and executing tests whenever any file changes
        autoWatch: true,

        // start these browsers
        // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
        browsers: ['Chrome','Firefox','IE'],

        // Continuous Integration mode
        // if true, Karma captures browsers, runs the tests and exits
        singleRun: false
    });
};

person seroth    schedule 13.05.2016    source источник
comment
Вы решили проблему, если да, то как?   -  person Jayson Minard    schedule 19.07.2016
comment
Я не сделал, я пошел в Мокко и использовал это.   -  person seroth    schedule 02.08.2016


Ответы (1)


Karma использует другой базовый путь во время выполнения, поэтому вам нужно добавить

System.config({
  baseURL: (typeof __karma__ !== "undefined") ? "base" : "/"
});

Имейте в виду, что этот базовый путь переопределяется каждый раз, когда вы запускаете jspm install, поэтому, если вы хотите автоматизировать свою среду, вам нужно создать собственное решение, чтобы добавить этот baseURL туда, где он был.

person Rytis Alekna    schedule 13.05.2016
comment
Я новичок в карме, не могли бы вы уточнить, пожалуйста. - person seroth; 13.05.2016
comment
Вы можете проверить мой рабочий проект с JSPM, Karma и Jasmine, например: github.com/ ralekna/fireworks-sequencer-program-generator - person Rytis Alekna; 15.05.2016