-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathserenity.config.ts
81 lines (76 loc) · 2.36 KB
/
serenity.config.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import { Before, BeforeAll, defineParameterType } from '@cucumber/cucumber';
import { actorCalled, actorInTheSpotlight, configure, engage } from '@serenity-js/core';
import path from 'path';
import { Actors } from '../../src';
/**
* @desc
* Set up Serenity/JS reporting services before any scenarios are executed
*
* @see https://serenity-js.org/handbook/reporting/index.html
*/
BeforeAll(function () {
configure({
crew: [
'@serenity-js/console-reporter',
'@serenity-js/serenity-bdd',
[ '@serenity-js/core:ArtifactArchiver', { outputDirectory: path.resolve(__dirname, `../../target/site/serenity`) } ],
// '@serenity-js/core:StreamReporter',
]
});
});
/**
* Engage Serenity/JS Actors before each scenario
*
* @see https://serenity-js.org/modules/core/function/index.html#static-function-engage
*/
Before(function () {
engage(new Actors(this.parameters.baseApiUrl));
});
/**
* @desc
* Map the '{actor}' token in Cucumber Expression to an Actor object referenced by a given name.
*
* @example
* import { Actor } from '@serenity-js/core';
* import { Given } from '@cucumber/cucumber';
*
* Given('{actor} is registered', (actor: Actor) =>
* actor.attemptsTo(
* // ...
* ));
*
* @see https://serenity-js.org/handbook/thinking-in-serenity-js/screenplay-pattern.html#actors
* @see https://cucumber.io/docs/cucumber/cucumber-expressions/
* @see https://serenity-js.org/modules/core/function/index.html#static-function-actorCalled
*/
defineParameterType({
regexp: /[A-Z][a-z]+/,
transformer(name: string) {
return actorCalled(name);
},
name: 'actor',
});
/**
* @desc
* Retrieve the most recently referenced actor using their pronoun.
*
* @example
* import { Actor } from '@serenity-js/core';
* import { Given } from '@cucumber/cucumber';
*
* Given('{pronoun} is registered', (actor: Actor) =>
* actor.attemptsTo(
* // ...
* ));
*
* @see https://serenity-js.org/handbook/thinking-in-serenity-js/screenplay-pattern.html#actors
* @see https://cucumber.io/docs/cucumber/cucumber-expressions/
* @see https://serenity-js.org/modules/core/function/index.html#static-function-actorCalled
*/
defineParameterType({
regexp: /he|she|they|his|her|their/,
transformer() {
return actorInTheSpotlight();
},
name: 'pronoun',
});