0

我正在使用 Karma 编写测试脚本,这是我的 karma.conf.js 代码

'use strict';

/**
 * Module dependencies.
 */
var _ = require('lodash'),
    karmaReporters = ['spec', 'coverage'];

//Karma configuration
module.exports = function (karmaConfig) {
  karmaConfig.set({

    preprocessors: {
      './index.html': ['ng-html2js'],
      './app/*/modules/*/views/**/*.html': ['ng-html2js'],
      './app/config.js': ['coverage'],
      './app/application.js': ['coverage'],
      './app/*/modules/*/client/*.js': ['coverage'],
      './app/*/modules/*/client/config/*.js': ['coverage'],
      './app/*/modules/*/client/controllers/*.js': ['coverage'],
      './app/*/modules/*/client/directives/*.js': ['coverage'],
      './app/*/modules/*/client/services/*.js': ['coverage']
    },

    ngHtml2JsPreprocessor: {
      moduleName: 'myApp',

      cacheIdFromPath: function (filepath) {
        return filepath;
      }
    },

    // List of files / patterns to load in the browser
    files: [
      './public/libs/angular/angular.js',
      './public/libs/angular-mocks/angular-mocks.js',
      './public/libs/angular-animate/angular-animate.js',
      './public/libs/angular-cookies/angular-cookies.js',
      './public/libs/angular-resource/angular-resource.js',
      './public/libs/angular-route/angular-route.js',
      './public/libs/angular-sanitize/angular-sanitize.js',
      './public/libs/angular-ui-router/release/angular-ui-router.js',
      './public/constants/constants.js',

      './app/config.js',
      './app/application.js',
      './app/*/modules/*/client/*.js',
      './app/*/modules/*/client/**/*.js',
      './app/*/modules/*/tests/unit/*.js',
      './index.html',
      './app/*/modules/*/client/views/**/*.html'
    ],
    basePath: './',
    //frameworks to use
    frameworks: ['jasmine'],

    // Test results reporter to use
    // Possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
    reporters: karmaReporters,

    // Configure the coverage reporter
    coverageReporter: {
      dir: './coverage/client',
      reporters: [
        // Reporters not supporting the `file` property
        {type: 'html', subdir: 'report-html'},
        {type: 'lcov', subdir: 'report-lcov'},
        // Output coverage to console
        {type: 'text'}
      ],
      instrumenterOptions: {
        istanbul: {noCompact: true}
      }
    },

    // Level of logging
    // Possible values: karmaConfig.LOG_DISABLE || karmaConfig.LOG_ERROR || karmaConfig.LOG_WARN ||
    // karmaConfig.LOG_INFO || karmaConfig.LOG_DEBUG
    logLevel: karmaConfig.LOG_INFO,

    browsers: ['Chrome'],
    autoWatch: true,
    singleRun: true,
    colors: true
  });
};

据我记得它在一段时间内工作正常,由于一些变化,我突然收到这个错误,我无法弄清楚可能是什么问题。

Uncaught Error: [$location:no/path/to/my/app] $location in HTML5 mode requires a </path/to/my/app> tag to be present!

我在索引文件中定义了基本 url,但在运行测试脚本时仍然出现此错误

4

0 回答 0