3

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.

user4955663
  • 1,039
  • 2
  • 13
  • 21

1 Answers1

1

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

adrobisch
  • 316
  • 1
  • 3