dimanche 11 juin 2017

scala play 2.5 testing views that needs implicit Flash

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?

Aucun commentaire:

Enregistrer un commentaire