Skip to content

root option

Zhouxuan Yang edited this page Feb 24, 2014 · 2 revisions

--root option

Let's assume that you have two projects named toy and other as follows:

toy/
  src/
    toy.js
  tests/
    runner.html
    toy-spec.js
other/
  src/
    outer.js

The test runner is toy/tests/runner.html, it includes the following scripts:

<script src="../src/toy.js"></script>
<script src="./toy-spec.js"></script>

If not specifies --roottotoro will give a static analysis of runner's HTML content, try to find out the least common parent directory of runner and all it's assets, and assign it to --root (in this example, is toy/).

Then, totoro will use --root as root to start a HTTP server, so totoro-server can visit this test runner via {{yourServer}}/tests/runner.

But, if ./toy-spec.js visits other/src/other.js out of toy/ in some way, such as:

$.ajax({url:'../../other/src/other.js'}).done(...)

The whole request path is {{yourServer}}/../other/src/other.js, obviously the HTTP server cannot handle this. Now, you need to specify --root=toy/../, let the parent directoy of toy/ to be the root of HTTP server, then all required files of test could be accessed correctly.

Clone this wiki locally