forked from puppeteer/replay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
47 lines (42 loc) · 1.31 KB
/
main.js
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
44
45
46
47
import { stringify, PuppeteerStringifyExtension } from '../../lib/main.js';
class Extension extends PuppeteerStringifyExtension {
// beforeAllSteps?(out: LineWriter, flow: UserFlow): Promise<void>;
async beforeAllSteps(...args) {
await super.beforeAllSteps(...args);
args[0].appendLine('console.log("starting");');
}
// beforeEachStep?(out: LineWriter, step: Step, flow: UserFlow): Promise<void>;
async beforeEachStep(...args) {
await super.beforeEachStep(...args);
const [out, step] = args;
out.appendLine(`console.log("about to execute step ${step.type}")`);
}
// afterEachStep?(out: LineWriter, step: Step, flow: UserFlow): Promise<void>;
async afterEachStep(...args) {
const [out, step] = args;
out.appendLine(`console.log("finished step ${step.type}")`);
await super.afterEachStep(...args);
}
// afterAllSteps?(out: LineWriter, flow: UserFlow): Promise<void>;
async afterAllSteps(...args) {
args[0].appendLine('console.log("finished");');
await super.afterAllSteps(...args);
}
}
console.log(
await stringify(
{
title: 'Test recording',
steps: [
{
type: 'navigate',
url: 'https://wikipedia.org',
},
],
},
{
extension: new Extension(),
indentation: ' ', // use tab to indent lines
}
)
);