Angular量角器:如何保证"no specs found"错误不发生?

Angular Protractor: How to ensure that "no specs found" error does not happen?

当我在 https://docs.angularjs.org/tutorial/step_02AngularJS 量角器测试 的教程时,我得到的错误消息是 "no specs found",当我运行进行e2e测试。这意味着 e2e 测试没有发生。我是量角器的新手,我在堆栈溢出中遇到过类似的问题,但这些并没有真正解决我的问题。

我不确定我是否缺少任何配置或者我是否从错误的目录发出命令。我的问题是如何确保"no specs found"错误不会发生?

我运行 /angular-phonecat/app 目录中的命令为:npm 运行 protractor

项目文件夹结构如下:

 angular-phonecat
     |_____app
          |_____app.js
          |_____app.spec.js
          |_____index.html
     |_____e2e-tests
           |_____protractor.conf.js

这是app.spec.js的内容:

'use strict';

describe('PhoneListController', function() {

  beforeEach(module('phonecatApp'));

  it('should create a `phones` model with 3 phones', inject(function($controller) {
    var scope = {};
    var ctrl = $controller('PhoneListController', {$scope: scope});

    expect(scope.phones.length).toBe(3);
  }));

});

Protractor.conf.js如下:

//jshint strict: false
exports.config = {

  allScriptsTimeout: 11000,

  specs: [
    '*.js'
  ],

  capabilities: {
    'browserName': 'chrome'
  },

  baseUrl: 'http://localhost:8000/',

  framework: 'jasmine',

  jasmineNodeOpts: {
    defaultTimeoutInterval: 30000
  }

};

端到端 (e2e) 测试,运行 使用量角器,仅在 step 5 上引入。因此,尝试 运行 前面步骤中的测试,将导致 "no specs found" 错误(正如预期的那样)。

您可能会对前面步骤中介绍的单元测试感到困惑。这些是不同类型的测试,并且 运行 具有不同的测试 运行ner(即 Karma,而不是 Protractor)。