-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathexampleFluentDslWithTypeScriptAndPageObjects.spec.ts
58 lines (48 loc) · 2.21 KB
/
exampleFluentDslWithTypeScriptAndPageObjects.spec.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
/**
* Example for using the new Scenarioo Fluent DSL with TypeScript Typings of ScenariooJS.
*
* For TypeScript typings we only support Fluent DSL as our newest and most comfortable API
* that is recommended to be used.
*
* Precondition for running this example using labels in Fluent DSL:
* All labels used in Scenarioo Fluent DSL have to be defined before usage.
* Usually we do this once on starting up the test suite.
* The example `./exampleFluentDslLabelDefinitions.js` demonstrates the declaration of all labels
* used in this examples.
*/
import {scenario, useCase} from '../../lib'; // use 'scenarioo-js' instead of '../../lib' in real project
// label definitions: usually only declared once on setup (no need to import in every test):
import './exampleFluentDslLabelDefinitions';
import {StartPage} from './pages/startPage';
/**
* The use case description
*/
useCase('Example Use Case with Fluent DSL in TypeScript')
.description('An optional but recommended description for the use case')
.labels(['example-custom-label'])
.describe(() => {
let startPage: StartPage;
beforeEach(async () => {
startPage = new StartPage();
await startPage.goTo();
});
/**
* A scenario description
*/
scenario('Example Scenario with Fluent DSL and reportStep Decorator')
.description('An optional but recommended description for the scenario')
.labels(['happy', 'example-label'])
.it(async () => {
// the StartPage constructor navigates us to index.html
// A step on a decorator could also have additional propoerties, like e.g. labels
await startPage.assertHeaderShown();
// do something on the page itself.
await startPage.selectFirstListItem();
// assert that the output changed as expected.
await startPage.assertSelected('one');
// The methods above are all decorated with the `reportStep` decorator, which lets them record new steps on the
// scenarioo api as if you would have called scenarioo.saveStep(...).
// This just helps making your e2e tests way more readable and you need to write less descriptive code.
// more steps of this scenario would of course come here ...
});
});