pickle-jar 1.4.1 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -42,8 +42,7 @@ In order to run the features and their steps, a test runner entry point must be
|
|
|
42
42
|
Create a file named `runner.ts` in the `<rootDir>/test` directory:
|
|
43
43
|
|
|
44
44
|
```ts
|
|
45
|
-
import {
|
|
46
|
-
import {StepDefinition, testRunner} from "../src";
|
|
45
|
+
import {StepDefinition, testRunner, FeatureContext} from "pickle-jar";
|
|
47
46
|
|
|
48
47
|
interface World {
|
|
49
48
|
password: string | undefined;
|
|
@@ -64,11 +63,20 @@ const stepDefinitions: StepDefinition<World>[] = [{
|
|
|
64
63
|
}
|
|
65
64
|
}];
|
|
66
65
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
66
|
+
// This function is called before each feature file is processed
|
|
67
|
+
// It can be used to initialize the World object
|
|
68
|
+
// The World object is passed to each step and allows sharing values from one step to another
|
|
69
|
+
// The FeatureContext object contains information about the feature file being processed
|
|
70
|
+
function worldFactory(featureContext: FeatureContext): World {
|
|
71
|
+
const world: World = {
|
|
72
|
+
password: undefined,
|
|
73
|
+
grantedAccess: false
|
|
74
|
+
}
|
|
75
|
+
return world;
|
|
70
76
|
}
|
|
71
|
-
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
testRunner<World>(`${__dirname}/features/**/*.feature`, stepDefinitions, worldFactory);
|
|
72
80
|
```
|
|
73
81
|
|
|
74
82
|
The test runner file defines the World object structure. This object is passed to each step and allows sharing values from one step to another.
|
|
@@ -104,8 +112,7 @@ Feature: Logging in
|
|
|
104
112
|
```
|
|
105
113
|
### `runner.ts` steps:
|
|
106
114
|
```ts
|
|
107
|
-
import {
|
|
108
|
-
import {StepDefinition, testRunner} from "../src";
|
|
115
|
+
import {StepDefinition, testRunner, FeatureContext} from "pickle-jar";
|
|
109
116
|
|
|
110
117
|
interface World {
|
|
111
118
|
password: string | undefined;
|
|
@@ -126,11 +133,16 @@ const stepDefinitions: StepDefinition<World>[] = [{
|
|
|
126
133
|
}
|
|
127
134
|
}];
|
|
128
135
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
136
|
+
function worldFactory(featureContext: FeatureContext): World {
|
|
137
|
+
const world: World = {
|
|
138
|
+
password: undefined,
|
|
139
|
+
grantedAccess: false
|
|
140
|
+
}
|
|
141
|
+
return world;
|
|
132
142
|
}
|
|
133
|
-
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
testRunner<World>(`${__dirname}/features/**/*.feature`, stepDefinitions, worldFactory);
|
|
134
146
|
```
|
|
135
147
|
|
|
136
148
|
## Running scenario outlines
|