Search code examples
staticassetsjs-test-driver

Static files not served by js-test-driver


I'm using js-test-driver to run some tests and would like to test some code against an html document. I was hoping to load this into the current document in an iframe and test my code against it but I'm having trouble even getting the file.

My directory structure is:

  • simpleJsTestDriver
    • aFile.html
    • aTest.js
    • jsTestDriver.conf
    • jsTestDriver.jar
    • someCode.js

afile.html

<!DOCTYPE html>
<html>
  <head>
  </head>
  <body>
    hello
  </body>
</html>

jsTestDriver.conf

server: http://localhost:9876

load:
  - "someCode.js"

test:
  - "aTest.js"

serve:
  - "aFile.html"

Running java -jar JsTestDriver.jar --port 9876 --runnerMode=DEBUG and navigating to http://localhost:9876/aFile.html gives:

HTTP ERROR 404

Problem accessing /aFile.html. Reason:

    Not found.
Powered by Jetty://

I'm using the latest version of js-test-driver (1.3.4.b) as 1.3.4.a appeared to have this problem of not serving static files. I know that the server finds the file okay as changing the name in the conf file to aFi.html throws the error:

Configuration Error: 
Cannot read [
/Users/james/Documents/simpleJSTestDriver/./aFi.html
] derived from aFi.html

Solution

  • Literally just solved it. You need to navigate to http://localhost:9876/test/aFile.html. Obviously!