istanbul-middleware icon indicating copy to clipboard operation
istanbul-middleware copied to clipboard

Support instrumentation via proxy, instead of from file system

Open lenntt opened this issue 8 years ago • 0 comments

I'd like to instrument code from an existing webserver (that has complex virtual dirs etc), instead of using the file system directly.

I don't think this is currently possible: http://stackoverflow.com/questions/39330914/getting-browser-test-coverage-via-a-proxy-with-istanbul-middleware

perhaps using express-http-proxy, make an example like this could work??

var path = require('path');
var im = require('istanbul-middleware');
var proxy = require('express-http-proxy');
var express = require('express');

var app = express();
var proxy = proxy('localhost:8383');
im.hookLoader(proxy);

app.use('/coverage', im.createHandler());
app.use( im.createClientHandler(proxy) );

app.listen(8889);

lenntt avatar Sep 09 '16 09:09 lenntt