我有一个angular网页,在那里我试图在Azure DevOps管道中运行E2E测试。
但是我的端到端测试运行了很长时间,没有产生任何结果。
不确定我遗漏了什么,我已经在下面分享了我的配置。
angular.json
"e2e": {
"fileReplacements": [
{
"replace": "src/app/core/services/auth.service.ts",
"with": "src/app/core/services/auth.service.mock.ts"
}
]
}package.json
"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
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:
- 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'发布于 2020-12-21 16:26:43
在运行自动化测试时,我建议使用浏览器的无头模式。
因此,您可以在protractor.conf.js文件中添加args: ["--headless", "--disable-gpu", "--incognito"]。
由于浏览器需要加载页面上的元素,e2e测试可能需要很长时间才能完成。因此,在某些情况下,它可能会因为无法加载元素而被卡住。无头测试摆脱了这种加载时间,允许您显著缩短测试时间。在我们使用无头测试的测试中,我们看到测试执行时间减少了30%。
https://stackoverflow.com/questions/65310141
复制相似问题