pickle-jar 1.4.0 → 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.
Files changed (2) hide show
  1. package/README.md +24 -12
  2. package/package.json +4 -2
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 {workerData} from "worker_threads";
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
- const world: World = {
68
- password: undefined,
69
- grantedAccess: false
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
- testRunner<World>(`${__dirname}/features/**/*.feature`, stepDefinitions, world);
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 {workerData} from "worker_threads";
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
- const world: World = {
130
- password: undefined,
131
- grantedAccess: false
136
+ function worldFactory(featureContext: FeatureContext): World {
137
+ const world: World = {
138
+ password: undefined,
139
+ grantedAccess: false
140
+ }
141
+ return world;
132
142
  }
133
- testRunner<World>(`${__dirname}/features/**/*.feature`, stepDefinitions, world);
143
+
144
+
145
+ testRunner<World>(`${__dirname}/features/**/*.feature`, stepDefinitions, worldFactory);
134
146
  ```
135
147
 
136
148
  ## Running scenario outlines
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pickle-jar",
3
- "version": "1.4.0",
3
+ "version": "1.4.2",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "repository": "git@github0.com:nseba/pickle-jar.git",
@@ -8,7 +8,9 @@
8
8
  "author": "Sebastian Negomireanu",
9
9
  "license": "MIT",
10
10
  "files": [
11
- "dist/src"
11
+ "dist/src",
12
+ "README.md",
13
+ "LICENSE"
12
14
  ],
13
15
  "devDependencies": {
14
16
  "@types/glob": "^8.1.0",