Q:

Websocket Unit test : WS from ScalaTestRouteTest doesnt do a websocket request

I am trying to put in place a unit test for websocket.  From the doc, I should be able to use WS
See below a sscce
package com.streamingout

import akka.http.scaladsl.model.ws. TextMessage
import akka.http.scaladsl.server. Directives._ 
import akka.http.scaladsl.server. PathMatchers. Rest
import akka.http.scaladsl.testkit.{ScalatestRouteTest, WSProbe}
import akka.stream.scaladsl.{Flow, Sink, Source}
import org.scalatest.{FlatSpec, Matchers}

class Test extends FlatSpec with Matchers with ScalatestRouteTest{

  //--------------- Flow ---------------
  def flow = {
    import scala.concurrent.duration._ 
    val source =  Source.tick(initialDelay = 0 second, interval = 1 second, tick = TextMessage("tick"))

    Flow.fromSinkAndSource(Sink.ignore, source)
  }

  //-------------- Routing ------------
  def route = {
    path("/wskt") {
      println("websocket ws")
      handleWebSocketMessages(flow)
    } ~
      path(Rest) { pathRest =>
        println("path Rest")
        getFromFile(s"webapp/$pathRest")
      }
  }

  // create a testing probe representing the client-side
  val wsClient = WSProbe()

  // WS creates a WebSocket request for testing
  WS("/wskt", wsClient.flow) ~> route ~> check {
    // check response for WS Upgrade headers
    isWebSocketUpgrade shouldEqual true

  }
}

When I run the test, I can see in my console the path Rest message, meaning that WS doesnt upgrade to Websocket. 
Anyone knows what is wrong with my code? 
I am using akka 2.4.7
Thank you

A:

To make the above code work, in the route, the path /wkst should be without any leading slash
def route = {
    path("wskt") {
      println("websocket ws")
      handleWebSocketMessages(flow)
    } ~
      path(Rest) { pathRest =>
        println("path Rest")
        getFromFile(s"webapp/$pathRest")
      }
  }

