Visit page without assert
JollyGood1 opened this issue · 1 comments
I found myself in need of this option in order to test redirects.
Example of how the use case looks:
Valid article slug test
$browser->visit(new ArticlePage("existing_article"));
(makes all required asserts)
Bad article slug test
$browser
->visitWithoutAssert(new ArticlePage("non_existing_article))
->on(new NotFoundPage);
(only uses the url, but avoids asserts. Instead it makes all required asserts on the redirected page)
The alternative is to make the url hardcoded in redirect situations, but that's not consistent, and doesn't seem right to me.
I thought maybe others will also have the same use case and will benefit this feature.
My apologies, I've never contributed to open source before so I don't actually know if this should be a pull requset or how to even make one. But my solution was this:
Add a boolean to the visit function
public function visit($url, bool $shouldAssert=true)
Add a little if inside the (isset($page))
if (isset($page)) {
if ($shouldAssert) {
$this->on($page);
}
else{
$this->onWithoutAssert($page);
}
}
I also made a little helper function
public function visitWithoutAssert($url){
$this->visit($url, false);
return $this;
}
What do you think?
Heya, thanks for submitting this.
This seems like a feature request or an improvement. For these, we'd appreciate a pull request instead so we can look at actual code. If you need feedback about an idea, we suggest to post an idea discussion here first. Please only use the issue tracker to report bugs and issues with this library.
Thanks!