简体   繁体   English

Karma Yeoman Grunt凉亭?

[英]Karma Yeoman Grunt bower?

Ok I have created my AngularJS project using Yeoman and this process 好的,我已经使用Yeoman和这个过程创建了AngularJS项目

which is working fine. 工作正常。 My question is how do i automate the creation of the test/spec folder to contain all of my lovely new angularJS code? 我的问题是我如何自动创建test / spec文件夹以包含我所有可爱的新angularJS代码? so i can then run karma, when i currently run karma it errors because i have edited the current controllers and such.. 这样我就可以运行因果报应,当我当前运行因果报应时会报错,因为我已经编辑了当前的控制器等。

    // 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/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
  });
};

the current error which makes perfect sense since I have removed the default $scope 当前的错误,因为我已经删除了默认的$ scope,因此非常合理

PhantomJS 1.9.7 (Linux) Controller: MainCtrl should attach a list of awesomeThings to the scope FAILED

this is my mainctrl file under test/spec/controllers/main.js that karma is looking for: 这是我的karma正在寻找的test / spec / controllers / main.js下的mainctrl文件:

    'use strict';

describe('Controller: MainCtrl', function () {

  // load the controller's module
  beforeEach(module('bawdApp'));

  var MainCtrl,
    scope;

  // Initialize the controller and a mock scope
  beforeEach(inject(function ($controller, $rootScope) {
    scope = $rootScope.$new();
    MainCtrl = $controller('MainCtrl', {
      $scope: scope
    });
  }));

  it('should attach a list of awesomeThings to the scope', function () {
    expect(scope.awesomeThings.length).toBe(3);
  });
});

and this is my current mainctrl file under app/scripts/controllers/main.js: 这是我当前在app / scripts / controllers / main.js下的mainctrl文件:

    'use strict';
/*global $:false */
angular.module('bawdApp')
    .controller('MainCtrl', function ($scope) {
    $(document).ready(function ($) {
        $('.page_cont_wrap').css('border', '0px solid #aaFFFF');
        var winhei = $(window).height();
        var windith = $(window).width();
        var onhundredpercentwidth = windith / 100;
        var thirtyfivewidth = Math.floor(onhundredpercentwidth * 35);
        var pathObj = {
            'fase1': {
                'strokepath': [{
                    'path': 'M10.077,64.579  C4.577,59.687,1.5,52.39,1.5,44.6c0-14.672,10.637-25.952,25.4-25.952c10.821,0,17.973,6.236,20.174,11.371V19.565V1.5h6.786v67.858  h-6.51V59.18c-2.225,4.154-5.718,7.712-10.625,9.743 M8.194,44.6v0.092c0.091,9.903,6.969,19.715,19.808,19.715  c5.502,0,10.545-2.201,14.03-5.777c3.576-3.667,5.685-8.711,5.502-14.213c0-5.594-2.109-10.362-5.686-13.847',
                    'duration': 200
                  }, {
                    'path': 'M108.329,18.648  c15.956,0,26.227,12.197,26.227,26.043c0,13.846-10.271,25.95-26.227,25.95c-15.863,0-26.134-12.104-26.134-25.95V44.6   M127.77,44.691c0-11.279-8.436-19.717-19.44-19.717c-10.912,0-19.44,8.438-19.44,19.717v0.091c0,11.188,8.528,19.624,19.44,19.624',
                    'duration': 200
                  }, {
                    'path': 'M208.099,41.298v28.06  h-6.693V42.674c0-10.637-4.77-17.881-15.865-17.699c-10.179,0.093-16.048,6.236-16.048,16.507 M169.492,69.358h-6.786V20.024h6.418  c0,2.751,0,5.502-0.091,8.803c2.843-6.419,9.537-10.363,18.339-10.179',
                    'duration': 200
                  }, {
                    'path': 'M243.86,18.557h-5.687  L244.595,1.5h6.418',
                    'duration': 200
                  }, {
                    'path': 'M284.117,1.5h6.694v18.524  h10.821v5.41h-10.821v23.246 M290.811,69.358h-6.694V25.434h-9.721v-5.41h9.721',
                    'duration': 200
                  }, {
                    'path': 'M393.181,32.32  l-11.463,35.946h-6.603l-8.112-23.34 M421.516,18.932h7.061l-17.057,49.333h-6.693 M357.968,18.932h7.152l13.572,40.622  l11.829-36.221h5.594l11.921,36.221',
                    'duration': 200
                  }, {
                    'path': 'M475.253,69.55  c-15.864,0-26.134-12.104-26.134-25.951v-0.091c0-13.756,10.271-25.952,26.134-25.952c15.956,0,26.227,12.196,26.227,26.043   M455.812,43.6v0.092c0,11.187,8.528,19.624,19.44,19.624c11.004,0,19.44-8.437,19.44-19.715c0-11.28-8.437-19.717-19.44-19.717',
                    'duration': 200
                  }, {
                    'path': 'M529.63,68.266V18.932  h6.419v8.069 M551.822,17.556v6.694h-0.643c-9.536,0-14.854,5.961-14.854,17.148v26.868',
                    'duration': 200
                  }, {
                    'path': 'M583.551,18.932v8.069  c3.575-7.335,9.994-9.261,15.772-9.445v6.694h-0.643 M583.825,41.398v26.868h-6.695V18.932',
                    'duration': 200
                  }, {
                    'path': 'M656.735,43.065  l-18.168,43.908h-7.337l8.438-19.624l-19.075-48.417h7.246l8.271,21.288 M643.335,58.821l15.958-39.889h7.426',
                    'duration': 200
                  }, {
                    'path': 'M686.528,58.088h7.243  l-6.877,17.056h-6.144',
                    'duration': 200
                  }, {
                    'path': 'M173.807,123.993  l-28.152,68.041h-7.335 M142.009,142.224l8.415,21.659l15.955-39.89 M146.755,172.412l-19.073-48.418h7.244',
                    'duration': 200
                  }, {
                    'path': 'M193.339,148.661v-0.091  c0-13.755,10.271-25.952,26.134-25.952c15.957,0,26.227,12.196,26.227,26.043c0,13.846-10.27,25.95-26.227,25.95 M219.474,128.946  c-10.913,0-19.44,8.436-19.44,19.715v0.091c0,11.188,8.527,19.624,19.44,19.624c11.004,0,19.44-8.436,19.44-19.715',
                    'duration': 200
                  }, {
                    'path': 'M273.759,123.993h6.694  v26.685c0,10.639,4.769,17.789,15.864,17.698 M312.456,151.87v-27.877h6.786v49.336h-6.419v-8.803  c-2.751,6.418-9.446,10.269-18.249,10.177c-15.406-0.274-20.816-10.728-20.816-22.74',
                    'duration': 200
                  }, {
                    'path': 'M444.32,123.993v49.336  h-6.787v-10.18c-3.85,7.43-11.371,11.554-20.174,11.554 M391.776,148.661c0-14.488,10.545-26.043,25.584-26.043  c10.546,0,17.791,6.145,20.174,11.738v-10.362 M418.094,128.854c-11.371,0-19.623,8.804-19.623,19.807v0.091  c0.091,8.896,6.235,19.624,19.806,19.624c8.71,0,15.131-5.042,17.789-12.011c1.102-2.384,1.652-5.137,1.652-7.795  c0.091-2.75-0.459-5.502-1.559-7.886',
                    'duration': 200
                  }, {
                    'path': 'M475.497,173.329v-49.336  h6.42v8.07 M497.69,122.618v6.695h-0.643c-9.537,0-14.854,5.96-14.854,17.147v26.87',
                    'duration': 200
                  }, {
                    'path': 'M558.761,158.656h7.061  c-2.293,5.319-5.777,9.354-9.996,12.013c-4.126,2.66-8.985,4.034-14.029,4.034c-17.149,0-26.043-13.662-26.043-25.952   M541.706,122.618c6.968,0,13.387,2.476,18.064,6.97c5.685,5.502,8.436,13.113,7.704,21H522.54  c0.367,12.379,10.913,18.339,19.257,18.248 M541.797,128.396c-10.637,0-18.523,7.794-19.166,16.781h38.147',
                    'duration': 200
                  }, {
                    'path': 'M125.861,219.899h6.787  v9.446h-6.787V219.899z M125.861,238.424h6.787v49.334h-6.787V238.424z',
                    'duration': 200
                  }, {
                    'path': 'M163.824,238.424h6.418  c0,2.751,0,5.502-0.091,8.804c2.843-6.421,9.537-10.361,18.34-10.178c15.314,0.182,20.724,10.637,20.724,22.65v28.058h-6.693  v-26.685c0-10.636-4.769-17.882-15.864-17.697c-10.179,0.091-16.047,6.234-16.047,16.506v27.876h-6.786V238.424z',
                    'duration': 200
                  }, {
                    'path': 'M326.682,301.514  c-4.86,4.768-12.013,7.609-18.707,7.609c-12.288,0-21.274-7.061-24.392-15.956h7.793 M308.158,303.256  c9.445,0,19.074-7.337,19.074-19.623v-6.328c-3.485,6.969-10.363,11.828-19.899,11.828c-15.406,0-25.768-11.735-25.768-25.949  c0-14.764,10.729-26.134,25.768-26.134c9.721,0,17.24,5.501,19.991,11.554v-10.18h6.694v43.648 M308.158,282.807  c5.594,0,10.362-2.108,13.847-5.686c3.393-3.575,5.411-8.526,5.502-13.938c0-4.127-1.375-8.987-4.493-12.93 M307.975,243.376  c-10.821,0-19.624,8.068-19.624,19.624v0.09',
                    'duration': 1000
                  }, {
                    'path': 'M414.439,263.09  c0,13.85-10.271,25.953-26.227,25.953c-15.864,0-26.134-12.104-26.134-25.953V263c0-13.756,10.271-25.95,26.134-25.95   M368.772,263.09v0.094c0,11.187,8.529,19.623,19.44,19.623c11.005,0,19.443-8.437,19.443-19.717  c0-11.278-8.438-19.714-19.443-19.714',
                    'duration': 200
                  }, {
                    'path': 'M439.562,263.09V263  c0-13.756,10.273-25.95,26.136-25.95c15.956,0,26.227,12.194,26.227,26.04c0,13.85-10.271,25.953-26.227,25.953 M465.699,243.376  c-10.913,0-19.44,8.436-19.44,19.714v0.094c0,11.187,8.527,19.623,19.44,19.623c11.004,0,19.44-8.437,19.44-19.717',
                    'duration': 200
                  }, {
                    'path': 'M569.41,219.899v67.858  h-6.51 M523.005,280.251c-3.846-4.689-5.956-10.801-5.956-17.251c0-14.674,10.636-25.95,25.399-25.95  c10.823,0,17.974,6.233,20.174,11.37v-10.454v-18.066 M562.9,277.58c-3.486,6.509-10.087,11.553-20.359,11.553 M523.743,263v0.09  c0.093,9.904,6.97,19.717,19.808,19.717c5.501,0,10.545-2.2,14.03-5.777c3.575-3.668,5.685-8.71,5.501-14.213  c0-5.593-2.108-10.363-5.685-13.848c-3.484-3.576-8.436-5.686-13.939-5.686',
                    'duration': 200
                  }, {
                    'path': 'M220.763,413.796h-6.694  v-26.319c0-5.318-1.1-9.812-3.576-13.021c-2.659-3.21-6.51-5.045-12.379-5.045 M175.372,413.796v-67.858h6.785v18.063v8.528  c3.027-6.509,10.638-9.628,17.606-9.444c7.794,0,12.93,2.477,16.323,6.785c3.393,4.312,4.676,10.271,4.676,17.332v10.524   M182.157,385.734v28.062',
                    'duration': 200
                  }, {
                    'path': 'M274.315,415.171  c-16.047,0-25.584-12.472-25.584-26.042c0-14.488,10.545-26.044,25.584-26.044c10.546,0,17.79,6.142,20.174,11.739v-10.363h6.785  v49.335h-6.785v-10.18 M255.425,389.129v0.091c0.092,8.896,6.235,19.624,19.807,19.624c8.712,0,15.131-5.043,17.791-12.014  c1.1-2.385,1.65-5.136,1.65-7.793c0.092-2.752-0.458-5.502-1.56-7.888',
                    'duration': 200
                  }, {
                    'path': 'M332.452,413.796v-49.335  h6.419c0,2.75,0,5.502-0.091,8.803 M371.15,395.769v-8.659c0-10.637-4.769-17.883-15.864-17.698  c-10.179,0.093-16.047,6.237-16.047,16.509v27.876 M357.12,363.085c15.314,0.182,20.724,10.638,20.724,22.649v28.062h-6.694',
                    'duration': 200
                  }, {
                    'path': 'M451.753,413.796v-10.18  c-3.484,6.511-10.086,11.555-20.357,11.555c-15.772,0-25.494-12.288-25.494-26.134 M417.668,366.851  c3.864-2.399,8.501-3.766,13.637-3.766c10.821,0,17.973,6.234,20.173,11.371v-10.455v-18.063h6.787v67.858 M446.252,375.005  c-3.484-3.574-8.438-5.686-13.939-5.686c-11.37,0-19.715,8.62-19.715,19.718v0.092c0.092,9.903,6.969,19.715,19.807,19.715  c5.502,0,10.545-2.201,14.03-5.778',
                    'duration': 200
                  }, {
                    'path': 'M493.385,399.766  c0.274,6.785,5.317,9.812,10.271,9.812 M494.852,376.656c0.184,4.677,3.76,6.604,9.72,8.345c7.062,1.924,14.948,3.943,15.315,14.489  c0.366,9.078-6.97,15.681-16.324,15.681c-7.977,0-16.78-5.044-16.873-15.405 M511.816,376.841c0-5.226-3.484-8.161-8.438-8.161   M513.191,400.314c-0.184-5.592-3.85-7.886-12.379-10.361c-7.06-2.11-12.562-4.952-12.746-12.747  c0-8.895,7.062-14.121,15.406-14.121c6.877,0,14.58,3.76,15.039,13.756',
                    'duration': 200
                  }],
                  'dimensions': {
                    'width': 699,
                    'height': 437
                  }
                }
              };
        var pathObjFour = {
            'fase4': {
                'strokepath': [{
                    'path': 'M ' + thirtyfivewidth + ',0 L  0,0  0,' + winhei + '  ' + windith + ',' + winhei + '   ' + windith + ',0   ' + thirtyfivewidth + ',0   ',
                    'duration': 6000
                  }],
                  'dimensions': {
                    'width': windith,
                    'height': winhei
                  }
                }
              };
        document.body.style.overflow = 'hidden';
        $('#fase1').css({
            'position': 'absolute',
            'left': '50%',
            'top': '50%',
            'margin-left': '-349.5px',
            'margin-top': '-218.5px'
          });
        $('#fase4').lazylinepainter({
            'svgData': pathObjFour,
            'strokeWidth': 25,
            'strokeColor': '#aaFFFF',
            'onComplete': function () {}
          }).lazylinepainter('paint');

        $('#fase1').lazylinepainter({
            'svgData': pathObj,
            'strokeWidth': 3,
            'strokeColor': '#aaFFFF',
            'onComplete': function () {
                setTimeout(function () {
                    window.location = '/new_site/#/home';
                  }, 200);

              }
          }).lazylinepainter('paint');
      });
  });

so how do i automatically sync these two up without having to rewrite manually the karma config file? 所以我如何自动同步这两个,而不必手动重写业力配置文件?

you don't have awesomeThings in your scope. 您的范围内没有真棒东西

you could just add 你可以添加

scope.awesomeThings = [1,2,3]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM