In my acceptance tests, I would like to simulate the back button click and results transitions.
I have the following, but I have a feeling that its wrong.
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'));
});
})
What's the right way to simulate back button in tests?
window.history.back()
or window.history.go(-1)
To make window.history.back()
work you need to use location : 'hash'
in your Router
App.Router.reopen({
location: 'hash'
});
Here's the official documentation about setting the location type: http://emberjs.com/guides/routing/specifying-the-location-api/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With