pickle-jar 3.0.0 → 4.0.0

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 +69 -8
  2. package/package.json +13 -7
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # pickle-jar
2
- pickle-jar is an alternative to jest-cucumber and and Cucumber.js that runs on top of jest. `pickle-jar`
3
- allows defining test scnearios using Gherkin language and translates them into define/it blocks that run using jest.
4
- Compared to jest-cucumber, the output is more explicit and all steps are reperesented by jest describe blocks.
2
+ pickle-jar is an alternative to jest-cucumber and Cucumber.js that runs on top of Jest or Vitest. `pickle-jar`
3
+ allows defining test scenarios using Gherkin language and translates them into describe/it blocks.
4
+ Compared to jest-cucumber, the output is more explicit and all steps are represented by describe blocks.
5
5
 
6
6
  [//]: <> (start placeholder for auto-badger)
7
7
 
@@ -162,10 +162,10 @@ const tagFilter = (tags: string[])=> {
162
162
  ```
163
163
  There are several builtin tags which are handled differently than custom tags:
164
164
 
165
- * `@skip` - when used, the step and sub-steps are completely skipped (they are handled as Jest `describe.only` or `it.only` calls)
166
- * `@only` - when used, only the steps and sub-steps are executed (they are handled as Jest `describe.only` or `it.only` calls)
167
- * `@todo` - when used, the step is marked as a TODO and no step code is executed (they are handled as Jest `it.todo` calls)
168
- * `@fail` - when used, the step is expected to fail (thye are handled as Jest `it.failed` calls)
165
+ * `@skip` - when used, the step and sub-steps are completely skipped (maps to `describe.skip` or `it.skip`)
166
+ * `@only` - when used, only the steps and sub-steps are executed (maps to `describe.only` or `it.only`)
167
+ * `@todo` - when used, the step is marked as a TODO and no step code is executed (maps to `it.todo`)
168
+ * `@fail` - when used, the step is expected to fail (maps to `it.failing` in Jest or `it.fails` in Vitest)
169
169
 
170
170
  ## Jest configuration
171
171
  Create a `jest.config.js` file in the project root (or update the existing one) to match the `runner.ts` file:
@@ -182,4 +182,65 @@ module.exports = {
182
182
  moduleFileExtensions: ['ts', 'js', 'html'],
183
183
  coverageDirectory: '../coverage/',
184
184
  };
185
- ```
185
+ ```
186
+
187
+ ## Using with Vitest
188
+
189
+ pickle-jar supports Vitest as an alternative to Jest. To use Vitest, pass the `vitestAdapter` in the options:
190
+
191
+ ### Install dependencies
192
+ ```shell
193
+ npm install vitest --dev
194
+ ```
195
+
196
+ ### Update runner.ts for Vitest
197
+ ```ts
198
+ import {StepDefinition, testRunner, vitestAdapter} from "pickle-jar";
199
+
200
+ interface World {
201
+ password: string | undefined;
202
+ grantedAccess: boolean;
203
+ }
204
+
205
+ const stepDefinitions: StepDefinition<World>[] = [{
206
+ match: /^Given I have previously created a password$/, step: (world) => {
207
+ world.password = "my password";
208
+ }
209
+ }, {
210
+ match: /^When I enter my password correctly$/, step: (world) => {
211
+ world.grantedAccess = world.password === 'my password';
212
+ }
213
+ }, {
214
+ match: /^I should be granted access$/, step: (world) => {
215
+ expect(world.grantedAccess).toBeTruthy();
216
+ }
217
+ }];
218
+
219
+ const createWorld = () => ({
220
+ password: undefined,
221
+ grantedAccess: false
222
+ });
223
+
224
+ testRunner<World>(
225
+ `${__dirname}/features/**/*.feature`,
226
+ stepDefinitions,
227
+ createWorld,
228
+ () => true,
229
+ { adapter: vitestAdapter }
230
+ );
231
+ ```
232
+
233
+ ### Vitest configuration
234
+ Create a `vitest.config.ts` file:
235
+ ```ts
236
+ import { defineConfig } from 'vitest/config';
237
+
238
+ export default defineConfig({
239
+ test: {
240
+ include: ['test/runner.ts'],
241
+ globals: true,
242
+ },
243
+ });
244
+ ```
245
+
246
+ Note: Vitest must be configured with `globals: true` for the adapter to work correctly.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pickle-jar",
3
- "version": "3.0.0",
3
+ "version": "4.0.0",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "repository": {
@@ -17,7 +17,7 @@
17
17
  ],
18
18
  "devDependencies": {
19
19
  "@types/glob": "^8.1.0",
20
- "@types/jest": "^29.5.14",
20
+ "@types/jest": "^30.0.0",
21
21
  "@typescript-eslint/eslint-plugin": "^8.27.0",
22
22
  "@typescript-eslint/parser": "^8.27.0",
23
23
  "antlr4": "^4.13.2",
@@ -25,15 +25,21 @@
25
25
  "antlr4ts-cli": "^0.5.0-alpha.4",
26
26
  "eslint": "^9.22.0",
27
27
  "eslint-config-prettier": "^10.1.1",
28
- "glob": "^11.0.1",
29
- "jest": "^29.7.0",
30
- "ts-jest": "^29.2.6",
31
- "tsc-watch": "^6.2.1",
28
+ "glob": "^13.0.0",
29
+ "jest": "^30.2.0",
30
+ "ts-jest": "^29.4.6",
31
+ "tsc-watch": "^7.2.0",
32
32
  "typescript": "^5.8.2"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "antlr4": "^4.13.0",
36
36
  "antlr4ts": "^0.5.0-alpha.4",
37
- "glob": "^10.2.6"
37
+ "glob": "^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0",
38
+ "vitest": "^1.0.0 || ^2.0.0 || ^3.0.0 || ^4.0.0"
39
+ },
40
+ "peerDependenciesMeta": {
41
+ "vitest": {
42
+ "optional": true
43
+ }
38
44
  }
39
45
  }