繁体   English   中英

在SystemJS上使用JSPM 404进行Karma / Jasmine单元测试设置

[英]Karma/Jasmine unit test setup with JSPM 404 on 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

我的karma.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
    });
};

业力在执行期间使用不同的基本路径,因此您必须添加到

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

请记住,每次运行jspm install都会覆盖此基本路径,因此,如果要自动化环境,则可以定制解决方案以将该baseURL添加回原来的位置。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM