加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angularjs – 如何修复我的发电机角项目,使咕噜测试工程?

发布时间:2020-12-17 08:38:57 所属栏目:安全 来源:网络整理
导读:我正在解决这个教程: http://www.sitepoint.com/kickstart-your-angularjs-development-with-yeoman-grunt-and-bower/作为一个手段来了解什么文件是使用yo generator-angular创建的。 我有使用AngularJS的经验,但是正在寻找一种方法来获得一个最佳实践目录
我正在解决这个教程: http://www.sitepoint.com/kickstart-your-angularjs-development-with-yeoman-grunt-and-bower/作为一个手段来了解什么文件是使用yo generator-angular创建的。

我有使用AngularJS的经验,但是正在寻找一种方法来获得一个最佳实践目录设置;我不知道如何设置依赖关系,并让我自己运行karma,因此使用yeoman发电机。

然而,直接开箱,没有编辑任何其他,当我运行grunt测试,我得到以下:

running "clean:server" (clean) task
Cleaning .tmp...OK

Running "concurrent:test" (concurrent) task

Running "copy:styles" (copy) task
Copied 1 files

Done,without errors

Running "autoprefixer:dist" (autoprefixer) task
Prefixed file ".tmp/styles/main.css" created.

Running "connect:test" (connect) task
Started connect web server on 127.0..0.1:9001.

Running "karma:unit" (karma) task
Warning: No provider for "framework:jasmine"! (resolving: framework:jasmine) Use --force to continue.

Aborted due to warnings.

我不明白为什么茉莉花没有提供者,而不知道如何解决这个问题。是固定我的package.json文件和更新节点的问题?

编辑:这里是配置文件:

// Karma configuration
// http://karma-runner.github.io/0.10/config/configuration-file.html

module.exports = function(config) {
  config.set({
    // base path,that will be used to resolve files and exclude
    basePath: '',// testing framework to use (jasmine/mocha/qunit/...)
    frameworks:['jasmine'],// list of files / patterns to load in the browser
    files: [
      'app/bower_components/angular/angular.js','app/bower_components/angular-mocks/angular-mocks.js','app/bower_components/angular-resource/angular-resource.js','app/scripts/*.js','app/scripts/**/*.js','test/mock/**/*.js','test/spec/**/*.js'
    ],// list of files / patterns to exclude
    exclude: [],// web server port
    port: 8080,// 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: ['Chrome'],// Continuous Integration mode
    // if true,it capture browsers,run tests and exit
    singleRun: false
  });

};

我似乎已经解决了我的问题,对于任何人有类似的问题:

在我的karma.conf.js中添加了以下内容:

plugins: [
    'karma-chrome-launcher','karma-jasmine'
    ],

起初我添加了’karma-jasmine’,但后来遇到“无法加载”Chrome“,它没有注册!这是通过添加’karma-chrome-launcher’作为插件解决

不知道是否是我的错误或发电机角度是否过时,但它现在工作。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读