1

In all of the examples on the Intern page, a static html file is serving up some front end framework (backbone, ember, etc). So in the functional test examples, the path to the static html file is being passed to the get method.

this.remote.get(require.toUrl('index.html'))

In my case, the rails application is serving up the html page which hosts the backbone app. Is there a way to have intern instrument the backbone app when it is being served up by rails? The only way I've found to get the functional tests to run is to pass the url of the running rails app to the get method. (running through nginx)

this.remote.get('http://localhost/')

While this allows the functional tests to run, it doesn't get passed through the listener on port 9000. Thus, I get no coverage stats.

Dirk Smaverson
  • 863
  • 7
  • 8

1 Answers1

2

Unfortunately, the instrumenting server is not configurable to attempt to retrieve files from another HTTP server, it will only read files from the local disk, so it’s not possible to use it as a pass-through for instrumenting the JavaScript served by a Rails app at this time unless those are actually being served statically by nginx (in which case you can set up a reverse proxy to Intern for your JavaScript files).

If you could reconfigure Rails to pull JavaScript from the instrumenting server instead of the filesystem, that would work. You can also try pre-instrumenting your JavaScript code by running the files through Istanbul’s command-line tool:

istanbul instrument --variable __internCoverage --no-compact --output output-dir input-dir
C Snover
  • 17,908
  • 5
  • 29
  • 39
  • To start, pre instrumenting the files with istanbul is a working solution for me, although it requires that i modify the file paths in my require js config to read from the instrumented file directory when testing. I think the nginx reverse proxy solution would be the cleaner solution, but I cant seem to get that to work. Since the javascript files are being served up by the rails asset pipeline, I reverse proxied the /assets/ directory to http://localhost:9000. Unfortunately, this resulted in a 502 (Bad Gateway) for any files in the assets directory. Not sure if there is a solution for this – Dirk Smaverson Mar 24 '14 at 19:50