You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
801 B
38 lines
801 B
2 years ago
|
'use strict';
|
||
|
|
||
|
const { Session } = require('inspector');
|
||
|
const { promisify } = require('util');
|
||
|
|
||
|
class CoverageInstrumenter {
|
||
|
constructor() {
|
||
|
this.session = new Session();
|
||
|
|
||
|
this.postSession = promisify(this.session.post.bind(this.session));
|
||
|
}
|
||
|
|
||
|
async startInstrumenting() {
|
||
|
this.session.connect();
|
||
|
|
||
|
await this.postSession('Profiler.enable');
|
||
|
|
||
|
await this.postSession('Profiler.startPreciseCoverage', {
|
||
|
callCount: true,
|
||
|
detailed: true,
|
||
|
});
|
||
|
}
|
||
|
|
||
|
async stopInstrumenting() {
|
||
|
const {result} = await this.postSession(
|
||
|
'Profiler.takePreciseCoverage',
|
||
|
);
|
||
|
|
||
|
await this.postSession('Profiler.stopPreciseCoverage');
|
||
|
|
||
|
await this.postSession('Profiler.disable');
|
||
|
|
||
|
return result;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
module.exports.CoverageInstrumenter = CoverageInstrumenter;
|