Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/20.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
Angularjs 如何正确地注入$IonicStory?_Angularjs_Ionic Framework_Jasmine_Karma Jasmine_Angular Mock - Fatal编程技术网

Angularjs 如何正确地注入$IonicStory?

Angularjs 如何正确地注入$IonicStory?,angularjs,ionic-framework,jasmine,karma-jasmine,angular-mock,Angularjs,Ionic Framework,Jasmine,Karma Jasmine,Angular Mock,我正在尝试使用jasmine在ionic应用程序控制器上运行单元测试。我的控制器接受$IonichStory作为参数。Im使用角度1和离子1 错误:[$injector:unpr]未知提供程序:$IonicstoryProvider您尝试注入\$Ionicstory\而不是$Ionicstory?是的,已经尝试过了。运气不好,你尝试注射\u$IonicStory\u而不是$IonicStory?是的,已经尝试过了。那里运气不好 describe('SignInController

我正在尝试使用jasmine在ionic应用程序控制器上运行单元测试。我的控制器接受$IonichStory作为参数。Im使用角度1和离子1


错误:[$injector:unpr]未知提供程序:$IonicstoryProvider您尝试注入
\$Ionicstory\
而不是
$Ionicstory
?是的,已经尝试过了。运气不好,你尝试注射
\u$IonicStory\u
而不是
$IonicStory
?是的,已经尝试过了。那里运气不好
        describe('SignInController', function(){
          var scope, controllerMock, deferredLogin, SignInServiceMock, stateMock, ionicHistoryMock;

          beforeEach(module('common.module'));
          beforeEach(module('utils.module'));
          beforeEach(module('api-client.module'));
          beforeEach(module('sign-in.module'));

          beforeEach(inject(function ($rootScope, $controller, $q, $ionicHistory) {
            scope = $rootScope.$new();
            ionicHistoryMock = $ionicHistory;
            deferredLogin = $q.defer();

            SignInServiceMock = {
              authentication: jasmine.createSpy('authentication spy')
                .and.returnValue(deferredLogin.promise)
            };

            stateMock = jasmine.createSpyObj('$state spy', ['go']);

            controllerMock = $controller('SignInController', {
              $scope: scope,
              $state: stateMock,
              $ionicHistory: ionicHistoryMock,
              SignInService: SignInServiceMock
            });

          }));

          it('scope should be defined', function () {
            expect(scope).toBeDefined();
          });

          it('SignInServiceMock should be defined', function () {
            expect(SignInServiceMock).toBeDefined();
          });

          it('controllerMock should be defined', function () {
            expect(controllerMock).toBeDefined();
          });

        });
  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: [
        '../www/lib/angular/angular.js',
        '../www/app/common/**',
        '../www/app/services/*.js',
        '../www/app/utils/*.js',
        '../www/app/sign-in/*.js',
        '../www/js/*.js',
        '../www/lib/angular-mocks/angular-mocks.js',
        '**/*tests.js'
      ],


      // list of files to exclude
      exclude: [
        '../www/app/common/language-translator/**',
        '../www/app/common/splash/update-data.json'
      ],


      // 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'],
      //browsers: ['PhantomJS'],


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

      // Concurrency level
      // how many browser should be started simultaneous
      concurrency: Infinity
    })
  };