【发布时间】:2016-01-13 00:12:09
【问题描述】:
我正在编写一个 Jasmine 自定义匹配器以在量角器规范中使用,并且我想检查浏览器标题是否等于某个字符串。我无法让这段代码正常工作,在花了几个小时调试它之后,我只能假设 browser 对象没有像我预期的那样在匹配器函数中被访问。当我修改匹配器函数以接受 browse.getTitle() 作为实际参数时,它可以正常工作,这导致了我的假设。谁能在这里找到问题并向我解释一下?
beforeEach(function() {
jasmine.addMatchers({
toBeOnPage: function(util, customEqualityTesters) {
return {
compare: function(actual, expected) {
var result = {};
result.pass = actual.getTitle() === expected.title;
return result;
}
};
}
});
});
var homepage = { url: 'Homepage URL', title: 'Homepage Title' };
describe('regression:', function() {
it('homepage loads successfully', function() {
browser.get('http://localhost/#/home');
expect(browser).toBeOnPage(homepage);
});
});
【问题讨论】:
标签: javascript testing jasmine protractor end-to-end