https://github.com/oresoftware/express-istanbul
Simple Node.js Express server that handles GET and POST of Istanbul test coverage data, using Istanbul standard middleware.
https://github.com/oresoftware/express-istanbul
expressjs istanbul istanbuljs nodejs test-coverage
Last synced: 9 months ago
JSON representation
Simple Node.js Express server that handles GET and POST of Istanbul test coverage data, using Istanbul standard middleware.
- Host: GitHub
- URL: https://github.com/oresoftware/express-istanbul
- Owner: ORESoftware
- Created: 2017-11-16T07:11:41.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-05-30T03:55:03.000Z (over 7 years ago)
- Last Synced: 2023-03-02T00:26:02.530Z (almost 3 years ago)
- Topics: expressjs, istanbul, istanbuljs, nodejs, test-coverage
- Language: JavaScript
- Homepage:
- Size: 1.95 KB
- Stars: 4
- Watchers: 2
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
### 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
```javascript
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:
```javascript
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();
}
};
```