提问者:小点点

为什么量角器(在Angular(v.4)项目中)找不到任何要测试的规范?


我在一个Angular(v.4)项目中工作,使用量角器时遇到了这个问题

从终端:

我/启动器-运行1个WebDriver实例

我/托管-在http://localhost:4444/wd/hub使用selenium服务器开始没有找到规格在0.003秒内完成

我/启动器-0个WebDriver实例仍在运行[17:06:38]I/启动器-chrome#01通过

它运行快速关闭的浏览器,并且它不运行(查找)任何规范。

protractor. conf.js:

require('ts-node/register');
var helpers = require('./helpers');

exports.config = {
  baseUrl: 'http://localhost:3000/',

  // use `npm run e2e`
  specs: [
    helpers.root('test/e2e/**/**.e2e.ts'),
    helpers.root('test/e2e/**/*.e2e.ts')
  ],
  exclude: [],

  framework: 'jasmine2',

  allScriptsTimeout: 110000,

  jasmineNodeOpts: {
    showTiming: true,
    showColors: true,
    isVerbose: false,
    includeStackTrace: false,
    defaultTimeoutInterval: 400000
  },

  directConnect: true,

  capabilities: {
    browserName: 'chrome',
    chromeOptions: {
      args: ["--headless", "--disable-gpu", "--window-size=800x600"]
    }
  },

  onPrepare: function () {
    browser.ignoreSynchronization = true;
  },

  /**
   * Angular 2 configuration
   *
   * useAllAngular2AppRoots: tells Protractor to wait for any angular2 apps on the page instead of just the one matching
   * `rootEl`
   */
  useAllAngular2AppRoots: true
};

文件夹结构

-/App
|--/config
   |--protractor.conf.js
   |--helpers.js 
   |--(all webpack files)
   |--(other stuff)
|--/node_modules
|--/src
|--/test
   |--/e2e
      |-mytest.e2e.ts
   |--/features
   |--/mockBackend
   |--/pages
      |-mypage.page.ts
   |--config.js

包. json

"cucumber": "^2",
"cucumber-html-reporter": "^3.0.4",
"cucumber-snippets-tsflow": "^1.0.2",
"cucumber-tsflow": "^2.2.0",
"protractor": "^5.1.2",
"protractor-cucumber-framework": "^3",
"protractor-snapshot": "^1.2.0",

共2个答案

匿名用户

我刚刚意识到您可能执行npm run e2e作为启动命令,表明您使用的是angel-cli或类似于run protractor。因此,在run-order中可能存在问题,而不是在路径定义中。据我所知,在方式上有一些更改/问题,protractor开始了,即在这里。

我建议试试这些:

  1. 将您的spesp-part放在功能中:{…}-part,因为这是量角器提供的。也许其中一个角cli配置需要那里而不是作为一个单独的部分
  2. 使用像Cliptor. js这样的config-helper-tools创建一个新的配置文件,然后比较与您的文件的差异。
  3. 通过执行命令protractor protractor. conf.js(来自官方量角器站点)而不是npm run e2e来直接启动量角器,以验证/伪造问题是否在angel-cliprotractor中。

匿名用户

任何路径都从存储protractor. conf.js的位置开始(所以你从config-文件夹开始)。给定提供的文件夹结构,我将从正常路径开始:

// use `npm run e2e`
specs: [
    //one level up, then below test/e2e/ all files ending with '.e2e.ts'
   // '../test/e2e/**/**.e2e.ts', //if *.ts is a file, no need for double ** 
    '../test/e2e/**/*.e2e.ts'  
],
exclude: [],

如果**. e2e.ts代表一个文件夹而不是一个文件,您的路径应该以/**e2e.ts/*.js结尾(或者您为测试文件本身选择的任何文件结尾)。

还有您的helpers. js-file,您应该将其作为var助手=需要('./helpers.js');

我看不出this. root背后是什么,我无法为helpers.root()提供一些东西

此外,您可能想使用TestSuites,或者您可能想构建一个帮助函数,您可以在其中从base-目录而不是conf. js的相对路径开始。查看这些链接:

测试套件vs规格。

baseDir而不是相对路径。

希望我能帮上忙。