问题描述
我正在开发一个服务于 2 个品牌的 Angular 应用程序 (V9)。在编写 e2e 测试时,我遇到了一个问题。每个品牌都有一个单独的网址,例如,brand1:“https://qa1.brandX.com”和brand2:“https://qa1.brandY.com”。
这是 protractor.conf.js 的代码
// Protractor configuration file,see link for more information
// https://github.com/angular/protractor/blob/master/lib/config.ts
const { SpecReporter } = require('jasmine-spec-reporter');
exports.config = {
sauceUser: 'username',sauceKey: 'key',allScriptsTimeout:20000,specs: [
'./src/**/*.e2e-spec.ts'
],multiCapabilities: [
{
browserName: 'chrome',version: 'latest',platform: 'Windows 10',name: 'chrome test demo','tunnel-identifier': 'getTunnel'',/**
* If this is set to be true,specs will be sharded by file (i.e. all
* files to be run by this set of capabilities will run in parallel).
* Default is false.
*/
shardTestFiles: true,/**
* Maximum number of browser instances that can run in parallel for this
* set of capabilities. This is only needed if shardTestFiles is true.
* Default is 1.
*/
maxInstances: 1,},{
browserName: 'firefox',name: 'demo-protractor-jasmine-ts','tunnel-identifier': 'getTunnel',{
browserName: 'MicrosoftEdge',name: 'Edge test test',}
],directConnect: false,framework: 'jasmine',useAllAngular2AppRoots: true,jasmineNodeOpts: {
showColors: true,defaultTimeoutInterval: 30000,print: function() {}
},onPrepare() {
browser.baseUrl = 'https://qa1.brandX.com';
require('ts-node').register({
project: require('path').join(__dirname,'./tsconfig.e2e.json')
});
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
}
};
这仅适用于我在单个 e2e 文件中包含一组测试的情况,即 app.e2e-spec.ts(对于品牌 X)。如果我想在brandY.e2e-spec.ts 中为brandY 运行另一组测试怎么办。 我应该如何为这组测试设置 baseurl?我试过了,但它总是在 https://qa1.brandX.com
上运行测试知道如何解决这个问题吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)