How do I run functional tests in Intern against a

2019-08-09 04:15发布

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.

标签: intern
1条回答
看我几分像从前
2楼-- · 2019-08-09 04:39

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
查看更多
登录 后发表回答