How to run ScalaJs tests in real browser?

465 Views Asked by At

Is it possible to run generated js test code in browser?

ScalaJS seems to generate following js files under target directory

(project-name)-test-fastopt.js
(project-name)-test-jsdeps.js

before running tests.

Is it possible to run these tests in browser e.g. using this type of html:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>The Scala.js Experimental</title>
  </head>
  <body>
    <!-- Include JavaScript dependencies -->
    <script type="text/javascript" src="./sjsexp2/js/target/scala-2.11/sjsexp2js-test-jsdeps.js"></script>
    <!-- Include Scala.js compiled code -->
    <script type="text/javascript" src="./sjsexp2/js/target/scala-2.11/sjsexp2js-test-fastopt.js"></script>

    <script type="text/javascript">
    $(function(){
    package.ClassName().mainFunction();
    })
    </script>

  </body>
</html>

If yes then what should be in place of "package.ClassName().mainFunction();"?

I'm using uTest framework for testing.

1

There are 1 best solutions below

0
On BEST ANSWER

There is a sbt plugin which provides a real browser environment for your tests using Selenium: https://github.com/scala-js/scala-js-env-selenium