首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ng配置--长时间运行的Azure DevOps中的e2e =e2e

ng配置--长时间运行的Azure DevOps中的e2e =e2e
EN

Stack Overflow用户
提问于 2020-12-16 00:47:14
回答 1查看 179关注 0票数 0

我有一个angular网页,在那里我试图在Azure DevOps管道中运行E2E测试。

但是我的端到端测试运行了很长时间,没有产生任何结果。

不确定我遗漏了什么,我已经在下面分享了我的配置。

angular.json

代码语言:javascript
复制
"e2e": {
         "fileReplacements": [
              {
                      "replace": "src/app/core/services/auth.service.ts",
                      "with": "src/app/core/services/auth.service.mock.ts"
               }
            ]
}

package.json

代码语言:javascript
复制
"scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "build-prod": "ng build --prod",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e --configuration=e2e"  
 }

protractor.conf.js

代码语言:javascript
复制
capabilities: {
    browserName: 'chrome',
    chromeOptions: {
      args: ["--incognito"]
    }
  },
  chromeDriver: '../node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_87.0.4280.88',
  baseUrl: 'http://localhost:4200/login',
  framework: 'custom',
  ignoreUncaughtExceptions: true,
  frameworkPath: require.resolve('protractor-cucumber-framework'),

My Pipele Yml:

代码语言:javascript
复制
- task: Npm@1
      displayName: 'npm Install'
      inputs:
        command: 'install'
        workingDir: './'
    - script: | 
                $(Agent.BuildDirectory)/s/node_modules/protractor/bin/webdriver-manager update --versions.chrome=chromedriver_87.0.4280.88
    - task: Npm@1
      displayName: 'E2E Testing'
      inputs:
        command: 'custom'
        workingDir: './'
        customCommand: 'run e2e'
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-12-21 16:26:43

在运行自动化测试时,我建议使用浏览器的无头模式。

因此,您可以在protractor.conf.js文件中添加args: ["--headless", "--disable-gpu", "--incognito"]

由于浏览器需要加载页面上的元素,e2e测试可能需要很长时间才能完成。因此,在某些情况下,它可能会因为无法加载元素而被卡住。无头测试摆脱了这种加载时间,允许您显著缩短测试时间。在我们使用无头测试的测试中,我们看到测试执行时间减少了30%。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65310141

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档