-
Notifications
You must be signed in to change notification settings - Fork 27
/
custom-world.ts
36 lines (31 loc) · 1.05 KB
/
custom-world.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
import { cliArgs, CliArgs } from './command-line-args';
import { setWorldConstructor } from 'cucumber';
import { Stream } from 'stream';
export type MediaType = 'text/plain' | 'image/png' | 'application/json';
export type AttachBuffer = (data: Buffer, mediaType: MediaType) => void;
export type AttachStream = (data: Stream, mediaType: MediaType) => void;
export type AttachText = (data: string) => void;
export type AttachStringifiedJson = (data: string, mediaType: 'application/json') => void;
export type AttachBase64EncodedPng = (data: string, mediaType: 'image/png') => void;
export type AttachFn =
| AttachBuffer
| AttachStream
| AttachBase64EncodedPng
| AttachStringifiedJson
| AttachText;
export interface CucumberWorldConstructorParams {
attach: AttachFn;
parameters: { [key: string]: string };
}
export class CustomWorld {
public attach: AttachFn;
public cliArgs: CliArgs;
/**
*
*/
constructor({ attach }: CucumberWorldConstructorParams) {
this.attach = attach;
this.cliArgs = cliArgs;
}
}
setWorldConstructor(CustomWorld);