Skip to content

Simple Node.js Express server that handles GET and POST of Istanbul test coverage data, using Istanbul standard middleware.

Notifications You must be signed in to change notification settings

ORESoftware/express-istanbul

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Purpose

This server will display test coverage data. The data is stored in the /coverage directory

Start the server, HTTP POST some data to the server, and then GET localhost:6969/coverage

Installing

git clone https://github.com/ORESoftware/express-istanbul.git
npm install

Running the server

node index.js or node . for short

Sending coverage

HTTP POST your coverage data to this server, using code of this nature:

exports.loadCoverage = function (driver, yourHost, yourPort) {

  return async function(cb) {

    await driver.switchTo().defaultContent();
    let obj = await driver.executeScript('return window.__coverage__;');

    let str = JSON.stringify(obj);
    let options = {
      port: 6969,
      host: 'localhost',
      path: '/coverage/client',
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      }
    };
    
    let req = http.request(options, res => {

      let data = '';
      // you *must* listen to data event
      // so that the end event will fire...
      res.on('data', d => {
        data += d;
      });

      res.once('end', function () {
       // Finished sending coverage data
       cb();  // fire the final callback
      });
    });
    
    req.write(str);
    req.end();

  }

};

About

Simple Node.js Express server that handles GET and POST of Istanbul test coverage data, using Istanbul standard middleware.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published