Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Christoffer Åström committed Oct 31, 2017
1 parent dcc9774 commit 898f94e
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/cdp/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ class Runner {
console.error(msg);
this.exit(1);
}
async extractCoverage() {
const { result: { value } } = await this.client.Runtime.evaluate({ expression: 'window.__coverage__;', returnByValue: true });
return value;
}
pipeOut(Runtime) {
Runtime.exceptionThrown((exception) => {
console.error('[chrome-exception]', exception);
Expand All @@ -69,18 +65,6 @@ class Runner {
console[type](...data);
});
}
async exit(code) {
if (this.options.coverage) {
global.__coverage__ = await this.extractCoverage(); // eslint-disable-line
this.nyc.writeCoverageFile();
this.nyc.report();
}
await this.client.close();
if (!this.options.debug) {
await this.chrome.kill();
}
this.mediator.emit('exit', code);
}
pipeError(Network) {
Network.requestWillBeSent(info => this.requests.set(info.requestId, info.request));
Network.loadingFailed((info) => {
Expand Down Expand Up @@ -122,6 +106,22 @@ class Runner {
await this.setup(files);
await this.navigate();
}
async extractCoverage() {
const { result: { value } } = await this.client.Runtime.evaluate({ expression: 'window.__coverage__;', returnByValue: true });
return value;
}
async exit(code) {
if (this.options.coverage) {
global.__coverage__ = await this.extractCoverage(); // eslint-disable-line
this.nyc.writeCoverageFile();
this.nyc.report();
}
await this.client.close();
if (!this.options.debug) {
await this.chrome.kill();
}
this.mediator.emit('exit', code);
}
}

module.exports = Runner;

0 comments on commit 898f94e

Please sign in to comment.