Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
配置karma/jasmine来测试angularjs抛出:没有提供程序;框架:茉莉花;!_Angularjs_Unit Testing_Karma Jasmine - Fatal编程技术网

配置karma/jasmine来测试angularjs抛出:没有提供程序;框架:茉莉花;!

配置karma/jasmine来测试angularjs抛出:没有提供程序;框架:茉莉花;!,angularjs,unit-testing,karma-jasmine,Angularjs,Unit Testing,Karma Jasmine,你好,我正在尝试用karma和jasmine为angularjs实现单元测试。因此,我遵循本教程: 在运行第一次测试时,由于一个错误,我被吸住了: “framework:jasmine”没有提供程序 我在谷歌上搜索了一下,并尝试了一些建议,比如再次安装karma jasmine和karma chrome launcher,但这些都不适合我 My package.json如下所示: { "name": "projectName", "version": "1.0.0", "descr

你好,我正在尝试用karma和jasmine为angularjs实现单元测试。因此,我遵循本教程:

在运行第一次测试时,由于一个错误,我被吸住了:

“framework:jasmine”没有提供程序

我在谷歌上搜索了一下,并尝试了一些建议,比如再次安装karma jasmine和karma chrome launcher,但这些都不适合我

My package.json如下所示:

{
  "name": "projectName",
  "version": "1.0.0",
  "description": "a description",
  "dependencies": {
    "gulp": "^3.5.6",
    "gulp-sass": "^1.3.3",
    "gulp-concat": "^2.2.0",
    "gulp-minify-css": "^0.3.0",
    "gulp-rename": "^1.2.0"
  },
  "devDependencies": {
    "bower": "^1.3.3",
    "gulp-util": "^2.2.14",
    "jasmine-core": "^2.3.4",
    "karma": "^0.12.36",
    "karma-chrome-launcher": "^0.1.12",
    "karma-jasmine": "^0.3.5",
    "karma-safari-launcher": "^0.1.1",
    "shelljs": "^0.3.0"
  },
  "cordovaPlugins": [
    "org.apache.cordova.device",
    "org.apache.cordova.console",
    "com.ionic.keyboard"
  ],
  "cordovaPlatforms": [
    "android",
    "ios"
  ]
}
和我的karma配置karma.conf.js:

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: ['jasmine'],


    // list of files / patterns to load in the browser
    files: [
      'test/*/Specs.js',
      'test/*'
    ],


    // 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 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_INFO,


    // 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', 'Safari'],


    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: false
  });
};

如果我运行
karma start karma.conf.js
我总是会得到错误。我甚至更改了这两个文件的权限,但没有任何效果。这里的问题是什么?

事实证明,我已经在全球安装了karma
npm安装-g karma
并且在本地安装了karma jasmine
npm安装karma jasmine
。我在全球重新安装了karma jasmine,现在它可以工作了

也许这对我找到这篇文章也有帮助,但对我来说并不奏效。