0

我们正在开发一个 Angular 项目,我们在其中使用 Karma/Jasmine 作为我们的测试环境。我们一直在使用 karma-chrome-launcher 来调试测试并且效果很好。由于某种原因,它最近停止了工作。我不知道为什么,因为我们没有改变任何关于那个管道的东西。我们尝试更新到最新的 Karma (1.4.1),但这并没有帮助。有没有其他人看到这个问题并能够解决它?帮助表示赞赏。我附上了两幅 Chrome 检查器在您第一次打开调试器时的样子,然后在设置断点并点击刷新后(它应该与第一张图像相同,但不一样)编辑: karma.config at底部也是

在此处输入图像描述

在此处输入图像描述

'use strict';

var path = require('path');
var conf = require('./gulp/conf');

var _ = require('lodash');
var wiredep = require('wiredep');

var pathSrcHtml = [
 path.join(conf.paths.src, '/**/*.html')
];

function listFiles() {
  var wiredepOptions = _.extend({}, conf.wiredep, {
   dependencies: true,
   devDependencies: true
  });

  var patterns = wiredep(wiredepOptions).js
   .concat([
    path.join(conf.paths.src, '/app/**/*.module.js'),
    path.join(conf.paths.src, '/app/**/*.js')
   ])
   .concat(pathSrcHtml)
   .concat('karmaMobileFramework/*.js');

   var files = patterns.map(function(pattern) {
    return {
     pattern: pattern
    };
   });
   files.push({
    pattern: path.join(conf.paths.src, '/assets/**/*'),
    included: false,
    served: true,
    watched: false
   });
 return files;
}

module.exports = function(config) {

var configuration = {

files: listFiles(),

singleRun: false,

autoWatch: true,

preprocessors : {
  '/**/*.html': ['ng-html2js']
},

ngHtml2JsPreprocessor: {
  stripPrefix: conf.paths.src + '/',
  moduleName: 'directive-templates'
},

logLevel: 'WARN',

frameworks: ['jasmine', 'jasmine-matchers', 'angular-filesort'],

angularFilesort: {
  whitelist: [path.join(conf.paths.src, '/**/!(*.html|*.spec|*.mock).js')]
},

browsers : ['Chrome'],

plugins : [
  'karma-chrome-launcher',
  'karma-angular-filesort',
  'karma-coverage',
  'karma-jasmine',
  'karma-jasmine-matchers',
  'karma-ng-html2js-preprocessor',
  'karma-htmlfile-reporter',
  'karma-junit-reporter'
],

coverageReporter: {
  type : 'html',
  dir : 'reports/coverage/',
  reporters: [
    { type: 'html', subdir: 'report-html' },
    { type: 'cobertura', subdir: 'report-jenkins' }
  ]
},

reporters: ['progress', 'html', 'junit'],

junitReporter: {
  outputDir: 'reports/tests/',
  outputFile: 'test-results.xml',
  useBrowserName: false
},

htmlReporter: {
  outputFile: 'reports/tests/results.html',
  pageTitle: 'BOLT Unit Tests'
},

 proxies: {
  '/assets/': path.join('/base/', conf.paths.src, '/assets/')
 }
};

 // This is the default preprocessors configuration for a usage with Karma cli
 // The coverage preprocessor is added in gulp/unit-test.js only for single tests
 // It was not possible to do it there because karma doesn't let us now if we are
 // running a single test or not
 configuration.preprocessors = {};
 pathSrcHtml.forEach(function(path) {
  configuration.preprocessors[path] = ['ng-html2js'];
 });

 config.set(configuration);
 };
4

0 回答 0