【问题标题】:jspm + KarmaJS - exclude files from watch but not from servejspm + Karma JS - 从手表中排除文件但不从服务器中排除文件
【发布时间】:2015-11-10 10:28:13
【问题描述】:

我不知道如何让业力不关注文件夹 jspm_packages/ 中的更改。 如果我尝试将“jspm_packages”添加到排除部分,则会出现以下错误:

调试 [web-server]:服务(缓存):/Users/jm/dev/monka/node_modules/gulp-helpers/node_modules/karma-jspm/src/adapter.js PhantomJS 1.9.8 (Mac OS X 0.0.0) 错误 ReferenceError:找不到变量:系统 在 /Users/jm/dev/monka/system.config.js:1 错误 [PhantomJS 1.9.8 (Mac OS X 0.0.0)]:ReferenceError:找不到变量:系统 在 http://localhost:9876/base/system.config.js?31f6cba38ed6c99ea3e9b4bc926e8ecfd6de8bd7:1

这是我的 karma.conf.js

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

    plugins: [
      'karma-jspm',
      'karma-jasmine',
      'karma-beep-reporter',
      'karma-verbose-reporter',
      'karma-babel-preprocessor',
      'karma-phantomjs-launcher'
    ],

    basePath   :  '',                 // base path that will be used to resolve all patterns (eg. files, exclude)
    frameworks : ['jspm', 'jasmine'], // frameworks to use available frameworks: https://npmjs.org/browse/keyword/karma-adapter
    browsers   : ['PhantomJS'],       // start these browsers available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
    reporters  : ['progress', 'beep', 'verbose'/*, 'coverage'*/], // test results reporter to use possible values: 'dots', 'progress' available reporters: https://npmjs.org/browse/keyword/karma-reporter
    singleRun  : false,  // Continuous Integration mode if true, Karma captures browsers, runs the tests and exits
    autoWatch  : true,  // Enable / disable watching file and executing tests whenever any file changes
    colors     : true,  // enable / disable colors in the output (reporters and logs)
    files      : [],    // list of files / patterns to load in the browser

    jspm: {
      config     : 'system.config.js',
      loadFiles  : ['test-unit/**/*.js'],
      serveFiles : ['dist/**/**']
    },

    proxies: {
      '/base/app'      : '/base/dist/app',
      '/base/common'   : '/base/dist/common',
      '/jspm_packages' : '/base/jspm_packages'
    },

    exclude: [
      'coverage/**',
      'typings/**',
      'dist/**/*.js.map'
    ],

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

    // preprocess matching files before serving them to the browser
    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
    preprocessors: {
      'src/**/*.js' : ['babel', 'coverage']
    },

    babelPreprocessor: {
      options: { sourceMap:'inline', modules:'system' }
    },

    coverageReporter: { type:'html', dir:'coverage/' }

  });
};

【问题讨论】:

    标签: karma-runner jspm gulp-karma


    【解决方案1】:

    我认为,使用 Karma 无法排除也应提供的文件被观看。 通过排除 jspm_packages,Karma 停止为位于 jspm_packages 文件夹中的 system.js 提供服务,因此未定义 System。

    如果您不想在测试运行期间提供 jspm_packages,您可以尝试在创建自执行包后运行测试,然后只提供该包。

    https://github.com/jspm/jspm-cli/blob/master/docs/production-workflows.md#creating-a-self-executing-bundle

    【讨论】:

      猜你喜欢
      • 2014-10-20
      • 1970-01-01
      • 2016-02-13
      • 1970-01-01
      • 2017-06-08
      • 2018-09-22
      • 2021-06-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多