How do I run functional tests in Intern against a backbone app being served up by rails?

StackOverflow https://stackoverflow.com/questions/22542712

  •  18-06-2023
  •  | 
  •  

Question

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.

Était-ce utile?

La solution

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
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top