【发布时间】:2017-11-24 00:11:42
【问题描述】:
我正在尝试在量角器中进行导航测试,并且没有看到与配置中的 baseUrl 和测试中使用的 url 有任何一致性。
量角器.conf.js
exports.config = {
baseUrl: 'http://localhost:4200/'
}
navbar.e2e-spec.ts
import { NavbarPage } from './navbar.po';
import * as protractor from './../protractor.conf.js';
describe('navbar', () => {
let navbar: NavbarPage;
const baseUrl = protractor.config.baseUrl;
beforeEach(() => {
navbar = new NavbarPage();
browser.get('/');
});
it(`should see showcase nav item, be able to (click) it,
and expect to be navigated to showcase page`, () => {
const anchorShowcase = navbar.anchorShowcase;
expect(anchorShowcase.isDisplayed()).toBe(true);
anchorShowcase.click();
browser.waitForAngular();
expect(browser.getCurrentUrl()).toBe(baseUrl + '/showcase');
});
});
虽然当我运行 e2e 测试时它使用不同的端口:
** NG Live Development Server is listening on localhost:49154, open your browser on http://localhost:49154/ **
为什么测试 url 设置为端口 49154。如果你启动一个新的 angular-cli 项目,这显然是默认的:https://github.com/angular/angular-cli
我如何才能控制 baseUrl / 或者 http://localhost:49154/ 是否可以安全地用于我的所有 angular cli 项目?
【问题讨论】:
标签: protractor angular-cli e2e-testing