-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
43 lines (34 loc) · 1007 Bytes
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import {
ConfigInterface,
TestInterface,
} from "@metrics-pli/types";
import * as EventEmitter from "events";
import Browser from "./lib/Browser";
import Test from "./lib/Test";
export { TYPES as ACTION_TYPES } from "./lib/constants";
export default class MetricsPli extends EventEmitter {
private session: Browser;
private test: Test;
constructor(
private tests: TestInterface[],
private config?: ConfigInterface,
) {
super();
this.session = new Browser(this.config);
this.test = new Test(this.session, this.tests);
this.session.on("error", this.handleError.bind(this));
this.test.on("error", this.handleError.bind(this));
this.test.on("data", this.handleData.bind(this));
}
public async run() {
await this.session.start();
await this.test.run();
await this.session.close();
}
private handleError(error: Error): void {
super.emit("error", error);
}
private handleData(data: Error): void {
super.emit("data", data);
}
}