gotwarlost / istanbul-middleware

Connect middleware for server side code coverage using istanbul
Other
179 stars 96 forks source link

Getting No coverage for file path when looking inside coverage path #22

Open KumarNellore opened 9 years ago

KumarNellore commented 9 years ago

I'm getting No coverage for file path []. In command prompt i can see message

Could not find file [d:\protractordemo\protractor-demo\public\angular.min.js], ignoring Could not find file [d:\protractordemo\protractor-demo\public\calc.js], ignoring

I"m testing with istanbul-middleware with https://github.com/juliemr/protractor-demo.

I created index.js file as shown in Istanbul-middleware example. And in expressserver.js file modifed content as below.

var util = require('util'); var path = require('path'), express = require('express'), url = require('url'), publicDir = path.resolve(__dirname, '..', 'public'), coverage = require('istanbul-middleware'), bodyParser = require('body-parser');

function matcher(req) {
    var parsed = url.parse(req.url);
    return parsed.pathname && parsed.pathname.match(/\.js$/) && !parsed.pathname.match(/jquery/);
}

module.exports = {
    start: function (port, needCover) {
        var app = express();
        if (needCover) {
            console.log('Turn on coverage reporting at /coverage');
            app.use('/coverage', coverage.createHandler({ verbose: true, resetOnGet: true }));
            app.use(coverage.createClientHandler(publicDir, { matcher: matcher }));
        }

        app.use(bodyParser.urlencoded({ extended: true }));
        app.use(bodyParser.json());

        app.set('view engine', 'hbs');
        app.engine('hbs', require('hbs').__express);
        app.use(express['static'](publicDir));
        app.use(express.static(__dirname));
        app.listen(port);
        console.log('Server running at http://localhost:'+port);
    }
};

and Started application from command prompt with command "node index.js"

I'm not able to get coverage.