Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/427.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
Javascript 测试因因果报应、吞咽和棱角而失败(来自约曼喷泉种子)_Javascript_Angularjs_Jasmine_Karma Jasmine_Yeoman - Fatal编程技术网

Javascript 测试因因果报应、吞咽和棱角而失败(来自约曼喷泉种子)

Javascript 测试因因果报应、吞咽和棱角而失败(来自约曼喷泉种子),javascript,angularjs,jasmine,karma-jasmine,yeoman,Javascript,Angularjs,Jasmine,Karma Jasmine,Yeoman,我尝试基于FountainJS种子定制一个angular项目(带有bower、js es5、sass和hello world应用程序的基本angular 1.6应用程序) 问题是,当我运行一个gulp测试时,测试失败了: PhantomJS 2.1.1 (Windows 7 0.0.0) hello component should render hello world FAILED forEach@bower_components/angular/angular.js:402:

我尝试基于FountainJS种子定制一个angular项目(带有bower、js es5、sass和hello world应用程序的基本angular 1.6应用程序)

问题是,当我运行一个
gulp测试时,测试失败了:

PhantomJS 2.1.1 (Windows 7 0.0.0) hello component should render hello world FAILED
        forEach@bower_components/angular/angular.js:402:24
        loadModules@bower_components/angular/angular.js:4880:12
        createInjector@bower_components/angular/angular.js:4802:30
        WorkFn@bower_components/angular-mocks/angular-mocks.js:3161:60
        loaded@http://localhost:9876/context.js:151:17
        bower_components/angular/angular.js:4921:53
PhantomJS 2.1.1 (Windows 7 0.0.0): Executed 1 of 1 (1 FAILED) ERROR (0.004 secs / 0.011 secs)
15 03 2017 14:44:20.072:DEBUG [karma]: Run complete, exiting.
15 03 2017 14:44:20.073:DEBUG [launcher]: Disconnecting all browsers
15 03 2017 14:44:20.082:DEBUG [launcher]: Process PhantomJS exited with code 0
15 03 2017 14:44:20.082:DEBUG [temp-dir]: Cleaning temp dir C:\Users\marmin-t\AppData\Local\Temp\karma-62828717
15 03 2017 14:44:20.089:DEBUG [launcher]: Finished all browsers
[14:44:20] 'karma:single-run' errored after 4.04 s
[14:44:20] Error: Failed 1 tests.
    at C:\xxx\angular1-front-seed\gulp_tasks\karma.js:15:22
    at removeAllListeners (C:\xxx\angular1-front-seed\node_modules\karma\lib\server.js:380:7)
    at Server.<anonymous> (C:\xxx\angular1-front-seed\node_modules\karma\lib\server.js:391:9)
    at Server.g (events.js:260:16)
    at emitNone (events.js:72:20)
    at Server.emit (events.js:166:7)
    at emitCloseNT (net.js:1537:8)
    at nextTickCallbackWith1Arg (node.js:431:9)
    at process._tickDomainCallback (node.js:394:17)
[14:44:20] 'test' errored after 4.46 s
我拥有由yeoman generator生成的默认hello组件:

hello.js

angular
  .module('app')
  .component('app', {
    templateUrl: 'app/hello.html',
    controller: function(config) {
      this.hello = 'Hello World!';
      this.config = config;
    }
  });
hello.html

<h1>{{ $ctrl.hello }}</h1>
<h2>Config:</h2>
<pre>{{ $ctrl.config | json }}</pre>
我为karma启用了调试日志级别,下面是测试启动时加载的文件:

少了什么?有什么想法吗

谢谢

<h1>{{ $ctrl.hello }}</h1>
<h2>Config:</h2>
<pre>{{ $ctrl.config | json }}</pre>
describe('hello component', function() {
  beforeEach(module('app', function($provide) {
    $provide.factory('app', function() {
      return {
        templateUrl: 'app/hello.html'
      };
    });
  }));
  it('should render hello world', angular.mock.inject(function($rootScope, $compile) {
    var element = $compile('<app>Loading...</app>')($rootScope);
    $rootScope.$digest();
    var h1 = element.find('h1');
    expect(h1.html()).toEqual('Hello World!');
  }));
});
15 03 2017 14:44:16.614:DEBUG [web-server]: Instantiating middleware
15 03 2017 14:44:16.691:WARN [watcher]: Pattern "C:/xxx/angular1-front-seed/src/assets/**/*" does not match any file.
15 03 2017 14:44:16.715:DEBUG [preprocessor.html2js]: Processing "C:/xxx/angular1-front-seed/src/app/hello.html".
15 03 2017 14:44:16.715:DEBUG [preprocessor.html2js]: Processing "C:/xxx/angular1-front-seed/src/index.html".
15 03 2017 14:44:16.739:DEBUG [karma-angular-filesort]: Sorted files:
        C:/xxx/angular1-front-seed/node_modules/jasmine-core/lib/jasmine-core/jasmine.js
        C:/xxx/angular1-front-seed/node_modules/karma-jasmine/lib/boot.js
        C:/xxx/angular1-front-seed/node_modules/karma-jasmine/lib/adapter.js
        C:/xxx/github/angular1-front-seed/node_modules/karma-phantomjs-shim/shim.js
        C:/xxx/github/angular1-front-seed/bower_components/angular/angular.js
        C:/xxx/angular1-front-seed/bower_components/angular-ui-router/release/angular-ui-router.js
        C:/xxx/angular1-front-seed/bower_components/angular-mocks/angular-mocks.js
        C:/xxx/angular1-front-seed/src/app/hello.html.js
        C:/xxx/angular1-front-seed/src/index.html.js
        C:/xxx/angular1-front-seed/.tmp/routes.js
        C:/xxx/angular1-front-seed/.tmp/app/hello.js
        C:/xxx/angular1-front-seed/.tmp/app/hello.spec.js