【问题标题】:use baseUrl from CLI instead of protractor config使用 CLI 中的 baseUrl 而不是量角器配置
【发布时间】:2019-04-12 09:30:56
【问题描述】:

我正在使用 Angular CLI 7 和量角器 5.4.2。 我希望我的量角器测试使用 CLI 中的 baseUrl 而不是量角器配置。 我已经尝试过以下方法。

ng e2e --base-url="https://google.com"

只看:

Option "baseUrl" is deprecated: Use "baseUrl" in the Protractor config file instead.
The 'baseUrl' option cannot be used with 'devServerTarget'.
When present, 'devServerTarget' will be used to automatically setup 'baseUrl' for Protractor.
Error: The 'baseUrl' option cannot be used with 'devServerTarget'.
When present, 'devServerTarget' will be used to automatically setup 'baseUrl' for Protractor.
    at ProtractorBuilder.run 

有没有人经历过这种情况?否则我该如何使用 baseUrl。

谢谢

【问题讨论】:

    标签: protractor angular-cli


    【解决方案1】:

    我做了以下技巧,它对我有用:

    我更新了我的 angular.json 文件并添加了一个新参数configurations

    "e2e": {
          "root": "e2e/",
          "projectType": "application",
          "prefix": "",
          "architect": {
            "e2e": {
              "builder": "@angular-devkit/build-angular:protractor",
              "options": {
                "protractorConfig": "e2e/local.js",
                "devServerTarget": "ng:serve"
              },
              "configurations": {
                "env": {
                  "protractorConfig": "e2e/protractorconf.js",
                  "devServerTarget": ""
                }
              }
            },
    

    当我运行时它可以工作

    ng e2e -c env --baseUrl="https://google.com"
    

    -c 是 angular.json 中指定的配置。

    更多选项请参考https://angular.io/cli/e2e

    【讨论】:

      【解决方案2】:

      试试这个,对我来说,它有效。

      protractor protractor.conf.js --params.baseUrl 'https://google.com'
      

      【讨论】:

        猜你喜欢
        • 2015-02-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-04-12
        • 2023-03-22
        • 2019-04-06
        相关资源
        最近更新 更多