@questi0nm4rk/feats 1.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.
- package/README.md +101 -0
- package/dist/feats.js +27862 -0
- package/dist/plugin/bun-plugin.js +12918 -0
- package/dist/src/assertions/config-assertions.d.ts +5 -0
- package/dist/src/assertions/output-assertions.d.ts +9 -0
- package/dist/src/cli/cli-result.d.ts +6 -0
- package/dist/src/cli/cli-runner.d.ts +8 -0
- package/dist/src/feats.d.ts +16 -0
- package/dist/src/fixtures/fixture-manager.d.ts +6 -0
- package/dist/src/fixtures/fixture-project.d.ts +12 -0
- package/dist/src/parser/adapter.d.ts +5 -0
- package/dist/src/parser/models.d.ts +35 -0
- package/dist/src/plugin/bun-plugin.d.ts +3 -0
- package/dist/src/random/seeded-rng.d.ts +8 -0
- package/dist/src/registry/expression-adapter.d.ts +6 -0
- package/dist/src/registry/parameter-types.d.ts +8 -0
- package/dist/src/registry/step-definition.d.ts +7 -0
- package/dist/src/registry/step-registry.d.ts +14 -0
- package/dist/src/reporting/error-formatter.d.ts +2 -0
- package/dist/src/reporting/pending-steps.d.ts +2 -0
- package/dist/src/runner/feature-runner.d.ts +9 -0
- package/dist/src/runner/hook-runner.d.ts +12 -0
- package/dist/src/runner/scenario-runner.d.ts +3 -0
- package/dist/src/runner/tag-filter.d.ts +2 -0
- package/dist/src/state/world.d.ts +4 -0
- package/dist/tests/assertions/config-assertions.test.d.ts +1 -0
- package/dist/tests/assertions/output-assertions.test.d.ts +1 -0
- package/dist/tests/cli/cli-runner.test.d.ts +1 -0
- package/dist/tests/features/self-test.steps.d.ts +1 -0
- package/dist/tests/features/self-test.test.d.ts +1 -0
- package/dist/tests/fixtures/sample-project/src/main.d.ts +1 -0
- package/dist/tests/fixtures-manager/fixture-manager.test.d.ts +1 -0
- package/dist/tests/parser/adapter.test.d.ts +1 -0
- package/dist/tests/parser/models.test.d.ts +1 -0
- package/dist/tests/random/seeded-rng.test.d.ts +1 -0
- package/dist/tests/registry/expression-adapter.test.d.ts +1 -0
- package/dist/tests/registry/parameter-types.test.d.ts +1 -0
- package/dist/tests/registry/step-registry.test.d.ts +1 -0
- package/dist/tests/reporting/error-formatter.test.d.ts +1 -0
- package/dist/tests/reporting/pending-steps.test.d.ts +1 -0
- package/dist/tests/runner/feature-runner.test.d.ts +1 -0
- package/dist/tests/runner/hook-runner.test.d.ts +1 -0
- package/dist/tests/runner/scenario-runner.test.d.ts +1 -0
- package/package.json +43 -0
- package/src/assertions/config-assertions.ts +123 -0
- package/src/assertions/output-assertions.ts +67 -0
- package/src/cli/cli-result.ts +6 -0
- package/src/cli/cli-runner.ts +66 -0
- package/src/feats.ts +30 -0
- package/src/fixtures/fixture-manager.ts +34 -0
- package/src/fixtures/fixture-project.ts +69 -0
- package/src/parser/adapter.ts +214 -0
- package/src/parser/models.ts +70 -0
- package/src/plugin/bun-plugin.ts +18 -0
- package/src/random/seeded-rng.ts +94 -0
- package/src/registry/expression-adapter.ts +34 -0
- package/src/registry/parameter-types.ts +24 -0
- package/src/registry/step-definition.ts +12 -0
- package/src/registry/step-registry.ts +63 -0
- package/src/reporting/error-formatter.ts +17 -0
- package/src/reporting/pending-steps.ts +16 -0
- package/src/runner/feature-runner.ts +86 -0
- package/src/runner/hook-runner.ts +54 -0
- package/src/runner/scenario-runner.ts +13 -0
- package/src/runner/tag-filter.ts +109 -0
- package/src/state/world.ts +5 -0
package/README.md
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# @questi0nm4rk/feats
|
|
2
|
+
|
|
3
|
+
BDD/Gherkin test framework for Bun — feature testing with typed step definitions.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
bun add @questi0nm4rk/feats
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick example
|
|
12
|
+
|
|
13
|
+
**`tests/features/checkout.feature`**
|
|
14
|
+
|
|
15
|
+
```gherkin
|
|
16
|
+
Feature: Shopping cart checkout
|
|
17
|
+
|
|
18
|
+
Scenario: Add item and checkout
|
|
19
|
+
Given the cart is empty
|
|
20
|
+
When I add "Widget" to the cart
|
|
21
|
+
Then the cart should have 1 item
|
|
22
|
+
And the total should be 9.99
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**`tests/features/checkout.steps.ts`**
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { Given, When, Then } from "@questi0nm4rk/feats";
|
|
29
|
+
|
|
30
|
+
interface CartWorld {
|
|
31
|
+
items: { name: string; price: number }[];
|
|
32
|
+
[key: string]: unknown;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
Given("the cart is empty", (world: CartWorld) => {
|
|
36
|
+
world.items = [];
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
When("I add {string} to the cart", (world: CartWorld, name: unknown) => {
|
|
40
|
+
if (typeof name !== "string") throw new Error("expected string");
|
|
41
|
+
world.items.push({ name, price: 9.99 });
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
Then("the cart should have {int} item", (world: CartWorld, count: unknown) => {
|
|
45
|
+
if (typeof count !== "number") throw new Error("expected number");
|
|
46
|
+
expect(world.items.length).toBe(count);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
Then("the total should be {float}", (world: CartWorld, total: unknown) => {
|
|
50
|
+
if (typeof total !== "number") throw new Error("expected number");
|
|
51
|
+
const sum = world.items.reduce((acc, item) => acc + item.price, 0);
|
|
52
|
+
expect(sum).toBe(total);
|
|
53
|
+
});
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**`tests/features/checkout.test.ts`**
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
import { loadFeatures, runFeatures } from "@questi0nm4rk/feats";
|
|
60
|
+
import "./checkout.steps";
|
|
61
|
+
|
|
62
|
+
const features = await loadFeatures("tests/features/*.feature");
|
|
63
|
+
runFeatures(features);
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Run with:
|
|
67
|
+
|
|
68
|
+
```sh
|
|
69
|
+
bun test
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Exports
|
|
73
|
+
|
|
74
|
+
| Export | Description |
|
|
75
|
+
|--------|-------------|
|
|
76
|
+
| `Given`, `When`, `Then`, `Step` | Register step definitions |
|
|
77
|
+
| `defineParameterType` | Register custom cucumber parameter types |
|
|
78
|
+
| `Before`, `After` | Lifecycle hooks (with optional tag filter) |
|
|
79
|
+
| `loadFeatures(glob)` | Parse `.feature` files matching a glob |
|
|
80
|
+
| `parseFeature(source, uri)` | Parse a feature from a string |
|
|
81
|
+
| `runFeatures(features, opts?)` | Generate `bun:test` describe/test blocks |
|
|
82
|
+
| `setupFixture(name, opts)` | Copy a fixture directory to a temp dir |
|
|
83
|
+
| `composeFixtures(names, opts)` | Merge multiple fixture dirs into one temp dir |
|
|
84
|
+
| `runCli(command, args?, opts?)` | Run a CLI process and capture output |
|
|
85
|
+
| `assertConfig(filePath, expected, opts?)` | Assert JSON/TOML/YAML config file contents |
|
|
86
|
+
| `assertOutput(result, expectations)` | Assert CLI output (stdout, stderr, exitCode) |
|
|
87
|
+
| `createRng(seed?)` | Create a seeded deterministic RNG |
|
|
88
|
+
|
|
89
|
+
## Bun plugin
|
|
90
|
+
|
|
91
|
+
Load `.feature` files directly as JS modules:
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
// bunfig.toml or Bun.build config
|
|
95
|
+
import featsPlugin from "@questi0nm4rk/feats/plugin";
|
|
96
|
+
|
|
97
|
+
Bun.build({
|
|
98
|
+
plugins: [featsPlugin],
|
|
99
|
+
// ...
|
|
100
|
+
});
|
|
101
|
+
```
|