【问题标题】:How to set up protractor tests with angular into separate suites?如何将带角度的量角器测试设置为单独的套件?
【发布时间】:2018-03-27 05:38:06
【问题描述】:

我有一个角度应用程序,我一直在使用量角器进行集成测试,可以使用 ng e2e 命令运行。现在它已设置好,以便我运行命令,它只运行 app.e2e-spec.ts 中的默认计划。我想在角度 cli 或量角器中配置运行不同计划(测试套件)的能力。因此,例如,我希望能够运行“ng e2e all”,例如运行贯穿我整个站点的测试计划。或者“ng e2e login”来运行一个只测试登录的计划。我该怎么做呢?这就是 Angular 项目中 e2e 文件夹的样子。以及 tsconfig.e2e.json 的样子。

{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/e2e",
    "baseUrl": "./",
    "module": "commonjs",
    "target": "es5",
    "types": [
      "jasmine",
      "jasminewd2",
      "node"
    ]
  }
}

【问题讨论】:

  • 我也在寻找同样的解决方案
  • 按照以下建议将套件添加到量角器文件,然后运行 ​​ng e2e --suite=

标签: angular protractor


【解决方案1】:

您可以将套件添加到 protractor.conf.js 文件中。

suites: {
  login: './e2e/login/**/*.e2e-spec.ts',
  admin: './e2e/admin/**/*.e2e-spec.ts',
  guest: './e2e/guest/**/*.e2e-spec.ts'
}

然后使用 protractor protractor.conf.js --suite login 运行登录测试

【讨论】:

  • 我只想添加一条评论,对于 Angular,建议的命令不起作用...我所做的是运行 ng e2e --suite=login ...。它有效。但有趣的是,随后显示的文本显示“选项 '--suite' 未使用 e2e 命令注册。运行 ng e2e --help 以获取支持的选项列表。” ...但它仍然有效。
【解决方案2】:

你可以利用 gulp 和 yargs 点击这里 (https://www.npmjs.com/package/yargs)

var args = require('yargs').argv;
gulp.task('e2e-test', ['webdriver_update'], function(cb) {
    gulp.src([]).pipe(gulpProtractor({
        configFile: './path/to/protractor.conf.js',
        args: [
            '--suite', args.suite
        ];
    })).on('error', function(e) {
        console.log(e);
    }).on('end', cb);
});

然后使用命令 -

gulp e2e-test --suite example

conf 文件中的套件标签将是 -

suites:{
    example:['./test/e2e/specs/**/*Spec.js',]
  },

【讨论】:

    猜你喜欢
    • 2017-10-18
    • 2018-06-17
    • 2021-02-09
    • 2019-09-22
    • 1970-01-01
    • 2013-12-06
    • 2016-05-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多