forked from hdorgeval/cucumber6-ts-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon-hooks.ts
52 lines (46 loc) · 1.26 KB
/
common-hooks.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
44
45
46
47
48
49
50
51
52
import { Before, BeforeAll } from "cucumber";
import { buildLogger, getLogger, ILogger } from "../loggers/common-logger";
import { NoOpLogger } from "../loggers/no-op-logger";
import { SimpleLogger } from "../loggers/simple-logger";
import { cliArgs, ICliArgs } from "./command-line-args";
// tslint:disable:only-arrow-functions
Before({tags: "@ignore"}, async function() {
return "skipped";
});
Before({tags: "@debug"}, async function() {
this.debug = true;
});
/**
* Before each scenario hook
*/
Before({tags: "@simpleLogger"}, async function() {
this.context = {
...this.context,
cliArgs,
logger: getLogger("@simpleLogger"),
};
});
/**
* Before each scenario hook
*/
Before({tags: "@simpleLogger and @debug"}, async function() {
this.context = {
...this.context,
cliArgs,
logger: getLogger("@simpleLogger@verbose"),
};
});
BeforeAll(async function() {
buildLogger(SimpleLogger)
.withName("@simpleLogger")
.withLevel(cliArgs.logLevel);
buildLogger(SimpleLogger)
.withName("@simpleLogger@verbose")
.withLevel("verbose");
buildLogger(NoOpLogger)
.withName("@noOpLogger");
});
export interface ICommonContext {
cliArgs: ICliArgs;
logger: ILogger;
}