How can i test a twirl view that require an implicit flash variables?
e.g.:
test
"render view" in new WithApplication {
contentAsString(views.html.index()) must contain("Hello")
}
twirl view:
@()(implicit flash: Flash)
<div>
@if(flash.get("error").isDefined) {
flash.get("error").getOrElse(""))
}
</div>
<p> Hello! </p>
in the test above, how can i pass an implicit flash:Flash
value/variable?
Do I need to inject in WithApplication
or extending that trait
?
enough to:
import play.api.mvc.Flash
"render view" in new WithApplication {
contentAsString(views.html.index()(new Flash()) must contain("Hello")
}