在我的验收测试中,我想模拟后退按钮点击和结果转换.
我有以下几点,但我觉得它错了.
test("back to search page", function(){
visit('/')
.then(function(){
return fillIn('.search input', 'hi');
})
.then(function(){
return click('.search button');
})
.then(function(){
// I want to go back here
return visit('/');
})
.then(function(){
var keyword = find('.search input').val();
equal(keyword, '');
ok(!exists('.search .results'));
});
})
Run Code Online (Sandbox Code Playgroud)
在测试中模拟后退按钮的正确方法是什么?
window.history.back()
要么 window.history.go(-1)