简体   繁体   English

在 Azure DevOps 管道中运行时,Angular/Protractor E2E 测试失败。 本地通过

[英]Angular/ Protractor E2E Test fails when run in Azure DevOps Pipeline. Passes locally

I am trying to run e2e tests on my angular application.我正在尝试在我的角度应用程序上运行 e2e 测试。 My tests pass locally when I run ng e2e but not in my pipeline.当我运行ng e2e但不在我的管道中时,我的测试在本地通过。 I'm going to share my protractor.conf, the pipeline tasks and the output I get from the task that fails below.我将分享我的 protractor.conf、管道任务和我从下面失败的任务中获得的输出。

Some more background:更多背景:

  • I am trying to run e2e code from an otherwise empty angular app.我正在尝试从一个空的角度应用程序运行 e2e 代码。 The test I am trying to run simply logs into AD by navigating to my website, entering a username/ password and then checking the that the user is redirected to my website.我尝试运行的测试只是通过导航到我的网站登录到 AD,输入用户名/密码,然后检查用户是否被重定向到我的网站。
  • I am running this from a release pipeline where the repo containing the e2e tests is added as an artifact.我正在从一个发布管道运行它,其中包含 e2e 测试的回购被添加为一个工件。
  • I am using xpaths to find elements on the page我正在使用 xpaths 在页面上查找元素
  • I've omitted my jasmine code because I do not think it is relevant since the tests pass locally.我省略了我的茉莉花代码,因为我认为它不相关,因为测试在本地通过。 However, if I'm wrong on this point let me know and I will post it.但是,如果我在这一点上错了,请告诉我,我会发布。

protractor.conf.js量角器.conf.js

const { SpecReporter } = require('jasmine-spec-reporter');

process.env.CHROME_BIN = process.env.CHROME_BIN || require("puppeteer").executablePath();

exports.config = {
  allScriptsTimeout: 11000,
  specs: [
    './src/**/*.e2e-spec.ts'
  ],
  capabilities: {
    chromeOptions: {
      args: ["--headless", "--disable-gpu", "--window-size=1200,900"],
      binary: process.env.CHROME_BIN
    },
    'browserName': 'chrome'
  },
  directConnect: true,
  baseUrl: 'http://localhost:4200/',
  framework: 'jasmine',
  jasmineNodeOpts: {
    showColors: true,
    defaultTimeoutInterval: 120000,
    print: function() {}
  },
  onPrepare() {
    require('ts-node').register({
      project: require('path').join(__dirname, './tsconfig.e2e.json')
    });
    jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
  }
};

Pipeline Tasks:流水线任务:
在此处输入图像描述

在此处输入图像描述

在此处输入图像描述

在此处输入图像描述

Failed Task Output:失败的任务输出: 在此处输入图像描述

Please help me get these tests to pass in azure请帮助我让这些测试顺利通过

Thanks!谢谢!

EDIT: I have that 'Update Webdriver' task because I read I should do it somewhere, it doesn't actually change the outcome if it is there or not编辑:我有那个“更新 Webdriver”任务,因为我读到我应该在某个地方做它,它实际上并没有改变结果,无论它是否存在

Have you tried to increase your allScriptsTimeout ?您是否尝试过增加allScriptsTimeout

The timeout in milliseconds for each script run on the browser.在浏览器上运行的每个脚本的超时时间(以毫秒为单位)。 This should be longer than the maximum time your application needs to stabilize between tasks.这应该比您的应用程序在任务之间稳定所需的最长时间要长。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM