【问题标题】:karma/jasmine angular tests fails on osxosx 上的业力/茉莉花角度测试失败
【发布时间】:2023-04-06 16:36:01
【问题描述】:

我有一个大型 Angular 应用程序,自项目开始以来,它的测试通过 grunt-karma/karma-jasmine 运行良好。最近,测试开始大部分时间都失败了,我不知道出了什么问题。

我有一个每次都有效的 git 提交,下一个大多数时候都失败,接下来的两个。我一直在摆弄它几个小时,却无法隔离任何可以使测试始终如一地通过的东西。每次我认为我已经找到了测试套件的绊脚石时,尝试使用这些知识之后的一些提交无论如何都会出错。

前 25 次测试总是通过,然后我收到一条错误消息,但并没有带来太多好处: Error: [$injector:modulerr] Failed to instantiate module app-module-common due to: Error: [$injector:unpr] Unknown provider: http://errors.angularjs.org/1.2.26/$injector/unpr?p0= at /Users/hudson/workspace/app-recast-master/build/js/bottom/vendor/dev/20-angular.js:3802 此消息中的奇怪之处在于没有指定提供者为未知。

这发生在负责构建站点的基于 osx 的机器上,但不是在我的 Windows 机器上。

这是 karma.conf 的样子:

(function () {
  'use strict';

  var exportedConf = require('./build.js');
  var userConfig = exportedConf.userConfig;

  module.exports = function (config) {

    config.set({
      // Karma configuration

      // base path, that will be used to resolve files and exclude
      basePath: '',

      // frameworks to use
      frameworks: ["jasmine"],

      // list of files / patterns to load in the browser
      files: [
        '../' + userConfig.build_dir + '/js/top/vendor/dev/**/*.js',
        //'../' + userConfig.build_dir + '/js/top/project-root/**/*.js',
        '../' + userConfig.src_dir + '/fragments/config.js',
        '../' + userConfig.build_dir + '/js/bottom/vendor/dev/**/*.js',
        '../' + userConfig.build_dir + '/js/bottom/project-root/**/*.js',
        '../test/mockFactory.js',
        '../test/jasmineVersionCheck.js',
        '../' + userConfig.project_dir + '/**/' + userConfig.tests_folderName + '/**/*.spec.js'
      ],

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

      preprocessors: {
        // preprocessors are defined at the end of file so that we can use the userConfig variables in the key
      },

      // test results reporter to use
      reporters: ['progress', 'junit', 'coverage'],

      coverageReporter: {
        dir: '../' + userConfig.reports_dir + '/',
        reporters: [
          {
            type: 'cobertura',
            file: 'coverage.xml'
          },
          {
            type: 'html',
            file: 'coverage.html'
          }
        ]
      },


      // web server port
      port: process.env.KARMA_PORT || 8080,

      // cli runner port
      runnerPort: process.env.KARMA_RUNNER_PORT || 9100,


      junitReporter: {
        outputFile: '../' + userConfig.reports_dir + '/test-results.xml'
      },



      // enable / disable colors in the output (reporters and logs)
      colors: process.env.KARMA_COLORS || true,

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

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

      // Start these browsers, currently available:
      // - Chrome
      // - ChromeCanary
      // - Firefox
      // - Opera
      // - Safari (only Mac)
      // - PhantomJS
      // - IE (only Windows)
      browsers: [process.env.KARMA_BROWSER || 'PhantomJS'],

      // If browser does not capture in given timeout [ms], kill it
      captureTimeout: 5000,

      // Continuous Integration mode
      // if true, it capture browsers, run tests and exit
      singleRun: true,

      plugins: ['karma-jasmine', 'karma-phantomjs-launcher', 'karma-junit-reporter', 'karma-coverage']


    });

    // polyfills need to be excluded or instanbul instrumentation goes wild and screws it all!
    config.preprocessors['../' + userConfig.build_dir + '/js/bottom/project-root/**/!(*-polyfills)+(.js)'] = ['coverage'];
  };
}());

希望有人能就此事给我一个提示,我已经用尽了所有我能想到的选项。

【问题讨论】:

    标签: angularjs macos gruntjs jasmine karma-runner


    【解决方案1】:

    也许,我真的说,也许,这可能是由于文件名的驼峰式。 IO 不考虑文件名的大小写。

    如果我有更好的想法,我会编辑我的答案。

    【讨论】:

    • 谢谢,但这听起来不太可能考虑到所有事情:/
    猜你喜欢
    • 1970-01-01
    • 2014-12-12
    • 1970-01-01
    • 2020-03-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-02
    • 1970-01-01
    相关资源
    最近更新 更多