在基于proxypass的AngularJS应用程序中使用量角器
我使用在AngularJS应用程序上实现端到端测试,我的应用程序使用代理传递来处理API调用。因此,在运行测试时,API调用会失败,因为在基于proxypass的AngularJS应用程序中使用量角器,angularjs,protractor,proxypass,Angularjs,Protractor,Proxypass,我使用在AngularJS应用程序上实现端到端测试,我的应用程序使用代理传递来处理API调用。因此,在运行测试时,API调用会失败,因为http://localhost:9000/api未被处理 我尝试了这个插件来处理/api代理传递,但它只是将(HTTP代码301)localhost:9000/api重定向到myserver.com/api,并且没有模仿代理传递的行为(应用程序也不工作) 以下是GrunFile配置: connect: { options: { port
http://localhost:9000/api
未被处理
我尝试了这个插件来处理/api
代理传递,但它只是将(HTTP代码301)localhost:9000/api
重定向到myserver.com/api
,并且没有模仿代理传递的行为(应用程序也不工作)
以下是GrunFile配置:
connect: {
options: {
port: 9000,
hostname: 'localhost',
base: ['<%= globals.appFolder %>/'],
logger: 'dev',
}
},
protractor: {
options: {
configFile: 'tests/e2e/protractor.config.js',
keepAlive: true,
noColor: false,
args: {}
},
e2e: {
options: {
args: {}
}
}
}
您将如何处理这种情况,让测试在桌面计算机和远程计算机上运行(如Jenkins)?根据grunt connect proxy上的相关信息,这是处理HTTPS端点时出现的错误。改用master/
版本
Package.json:
"grunt-connect-proxy": "https://github.com/drewzboto/grunt-connect-proxy#master",
Grunfile:
proxies: [{
context: '/api',
host: 'myserver.com',
port: 443,
https: true
}]
proxies: [{
context: '/api',
host: 'myserver.com',
port: 443,
https: true
}]