@esimplicitylabs/katalyst-xspec 0.6.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/LICENSE +7 -0
- package/README.md +69 -0
- package/bin/katalyst-xspec.cjs +54 -0
- package/cli/init.cjs +679 -0
- package/cli/stubs.cjs +365 -0
- package/cli/upgrade.cjs +1014 -0
- package/dist/chunk-ACAXOGKZ.js +1611 -0
- package/dist/index.d.ts +881 -0
- package/dist/index.js +1091 -0
- package/dist/steps/index.d.ts +151 -0
- package/dist/steps/index.js +50 -0
- package/package.json +80 -0
- package/scripts/postinstall.cjs +85 -0
- package/skills/katalyst-bdd-architecture/SKILL.md +517 -0
- package/skills/katalyst-bdd-architecture/references/adapters.md +310 -0
- package/skills/katalyst-bdd-architecture/references/custom-steps.md +360 -0
- package/skills/katalyst-bdd-architecture/references/ports.md +256 -0
- package/skills/katalyst-bdd-create-test/SKILL.md +366 -0
- package/skills/katalyst-bdd-create-test/references/api-patterns.md +371 -0
- package/skills/katalyst-bdd-create-test/references/hybrid-patterns.md +420 -0
- package/skills/katalyst-bdd-create-test/references/tui-patterns.md +458 -0
- package/skills/katalyst-bdd-create-test/references/ui-patterns.md +415 -0
- package/skills/katalyst-bdd-quickstart/SKILL.md +292 -0
- package/skills/katalyst-bdd-step-reference/SKILL.md +147 -0
- package/skills/katalyst-bdd-step-reference/references/api-steps.md +247 -0
- package/skills/katalyst-bdd-step-reference/references/shared-steps.md +340 -0
- package/skills/katalyst-bdd-step-reference/references/tui-steps.md +483 -0
- package/skills/katalyst-bdd-step-reference/references/ui-steps.md +521 -0
- package/skills/katalyst-bdd-troubleshooting/SKILL.md +449 -0
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
# UI Test Patterns
|
|
2
|
+
|
|
3
|
+
Common patterns for UI testing with the Katalyst BDD framework.
|
|
4
|
+
|
|
5
|
+
## Navigation Patterns
|
|
6
|
+
|
|
7
|
+
### Basic Navigation
|
|
8
|
+
|
|
9
|
+
```gherkin
|
|
10
|
+
@ui
|
|
11
|
+
Scenario: Navigate to page
|
|
12
|
+
Given I navigate to "/dashboard"
|
|
13
|
+
Then I should see text "Dashboard"
|
|
14
|
+
And the URL should contain "/dashboard"
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### Navigation with Auth
|
|
18
|
+
|
|
19
|
+
```gherkin
|
|
20
|
+
@ui
|
|
21
|
+
Scenario: Navigate after login
|
|
22
|
+
Given I am authenticated in UI as "user"
|
|
23
|
+
Given I navigate to "/profile"
|
|
24
|
+
Then I should see text "My Profile"
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Back Navigation
|
|
28
|
+
|
|
29
|
+
```gherkin
|
|
30
|
+
@ui
|
|
31
|
+
Scenario: Go back to previous page
|
|
32
|
+
Given I navigate to "/page1"
|
|
33
|
+
When I click the link "Go to Page 2"
|
|
34
|
+
Then the URL should contain "/page2"
|
|
35
|
+
When I go back in the browser
|
|
36
|
+
Then the URL should contain "/page1"
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Login Patterns
|
|
40
|
+
|
|
41
|
+
### Simple Login Form
|
|
42
|
+
|
|
43
|
+
```gherkin
|
|
44
|
+
@ui
|
|
45
|
+
Scenario: User login
|
|
46
|
+
Given I navigate to "/login"
|
|
47
|
+
When I fill in "Email" with "user@example.com"
|
|
48
|
+
And I fill in "Password" with "password123"
|
|
49
|
+
And I click the button "Sign In"
|
|
50
|
+
Then I should see text "Welcome"
|
|
51
|
+
And the URL should contain "/dashboard"
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Login with Fetch Intercept (Bypassing Auth)
|
|
55
|
+
|
|
56
|
+
```gherkin
|
|
57
|
+
@ui
|
|
58
|
+
Scenario: Test page as authenticated user
|
|
59
|
+
Given I am authenticated in UI as "admin"
|
|
60
|
+
Given I navigate to "/admin/dashboard"
|
|
61
|
+
Then I should see text "Admin Dashboard"
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Login with Specific Roles
|
|
65
|
+
|
|
66
|
+
```gherkin
|
|
67
|
+
@ui
|
|
68
|
+
Scenario: Test with multiple roles
|
|
69
|
+
Given I am authenticated in UI as "admin,manager,editor"
|
|
70
|
+
Given I navigate to "/settings"
|
|
71
|
+
Then I should see text "Admin Settings"
|
|
72
|
+
And I should see text "Manager Settings"
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Login with Tenant
|
|
76
|
+
|
|
77
|
+
```gherkin
|
|
78
|
+
@ui
|
|
79
|
+
Scenario: Multi-tenant login
|
|
80
|
+
Given I am authenticated in UI as "admin" for tenant "acme-corp"
|
|
81
|
+
Given I navigate to "/dashboard"
|
|
82
|
+
Then I should see text "ACME Corp Dashboard"
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Form Patterns
|
|
86
|
+
|
|
87
|
+
### Simple Form Fill
|
|
88
|
+
|
|
89
|
+
```gherkin
|
|
90
|
+
@ui
|
|
91
|
+
Scenario: Fill contact form
|
|
92
|
+
Given I navigate to "/contact"
|
|
93
|
+
When I fill in "Name" with "John Doe"
|
|
94
|
+
And I fill in "Email" with "john@example.com"
|
|
95
|
+
And I fill in "Message" with "Hello, this is a test message."
|
|
96
|
+
And I click the button "Send"
|
|
97
|
+
Then I should see text "Message sent"
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Form with Data Table
|
|
101
|
+
|
|
102
|
+
```gherkin
|
|
103
|
+
@ui
|
|
104
|
+
Scenario: Fill registration form
|
|
105
|
+
Given I navigate to "/register"
|
|
106
|
+
When I fill the form:
|
|
107
|
+
| Field | Value |
|
|
108
|
+
| First Name | John |
|
|
109
|
+
| Last Name | Doe |
|
|
110
|
+
| Email | john.doe@example.com |
|
|
111
|
+
| Password | SecurePass123! |
|
|
112
|
+
| Confirm Password | SecurePass123! |
|
|
113
|
+
And I click the button "Register"
|
|
114
|
+
Then I should see text "Account created"
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Form with Dropdowns
|
|
118
|
+
|
|
119
|
+
```gherkin
|
|
120
|
+
@ui
|
|
121
|
+
Scenario: Fill form with dropdown
|
|
122
|
+
Given I navigate to "/settings"
|
|
123
|
+
When I fill in "Display Name" with "John"
|
|
124
|
+
And I select "Dark" from dropdown "Theme"
|
|
125
|
+
And I select "English" from dropdown "Language"
|
|
126
|
+
And I click the button "Save"
|
|
127
|
+
Then I should see text "Settings saved"
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Clear and Fill Form
|
|
131
|
+
|
|
132
|
+
```gherkin
|
|
133
|
+
@ui
|
|
134
|
+
Scenario: Update existing form data
|
|
135
|
+
Given I navigate to "/profile/edit"
|
|
136
|
+
When I clear and fill the form:
|
|
137
|
+
| Field | Value |
|
|
138
|
+
| Name | Updated Name |
|
|
139
|
+
| Bio | Updated bio |
|
|
140
|
+
And I click the button "Save"
|
|
141
|
+
Then I should see text "Profile updated"
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Form Validation
|
|
145
|
+
|
|
146
|
+
```gherkin
|
|
147
|
+
@ui
|
|
148
|
+
Scenario: Form shows validation errors
|
|
149
|
+
Given I navigate to "/register"
|
|
150
|
+
When I fill in "Email" with "invalid-email"
|
|
151
|
+
And I click the button "Register"
|
|
152
|
+
Then I should see text "Invalid email format"
|
|
153
|
+
And the element ".error-message" should be visible
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## Click Patterns
|
|
157
|
+
|
|
158
|
+
### Click Button
|
|
159
|
+
|
|
160
|
+
```gherkin
|
|
161
|
+
When I click the button "Submit"
|
|
162
|
+
When I click the "Save" button
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Click Link
|
|
166
|
+
|
|
167
|
+
```gherkin
|
|
168
|
+
When I click the link "Learn More"
|
|
169
|
+
When I click the link "Terms of Service"
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### Click Element by Selector
|
|
173
|
+
|
|
174
|
+
```gherkin
|
|
175
|
+
When I click the element "#submit-btn"
|
|
176
|
+
When I click the element ".menu-item.active"
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Click Element with Text
|
|
180
|
+
|
|
181
|
+
```gherkin
|
|
182
|
+
When I "click" the "button" element that contains "Save Changes"
|
|
183
|
+
When I "force click" the "first" element with "test ID" "action-btn"
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Conditional Click
|
|
187
|
+
|
|
188
|
+
```gherkin
|
|
189
|
+
When If its visible, I "click" the "first" element with "text" "Dismiss"
|
|
190
|
+
When If its visible, I "click" the "first" element with "role" "button"
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
## Assertion Patterns
|
|
194
|
+
|
|
195
|
+
### Text Assertions
|
|
196
|
+
|
|
197
|
+
```gherkin
|
|
198
|
+
Then I should see text "Welcome"
|
|
199
|
+
Then I should see text "User {userName}"
|
|
200
|
+
Then I should not see text "Error"
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### URL Assertions
|
|
204
|
+
|
|
205
|
+
```gherkin
|
|
206
|
+
Then the URL should contain "/dashboard"
|
|
207
|
+
Then I should be on page "/users"
|
|
208
|
+
Then I verify if the URL "equals" "https://example.com/home"
|
|
209
|
+
Then I verify if the URL "doesntContain" "error"
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### Element Visibility
|
|
213
|
+
|
|
214
|
+
```gherkin
|
|
215
|
+
Then the element "#modal" should be visible
|
|
216
|
+
Then the element ".error" should not be visible
|
|
217
|
+
Then I verify that a "button" element with "Submit" text "is" visible
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### Element State
|
|
221
|
+
|
|
222
|
+
```gherkin
|
|
223
|
+
Then I verify that "first" element with "test ID" "submit" is "enabled"
|
|
224
|
+
Then I verify that "first" element with "label" "Email" is "editable"
|
|
225
|
+
Then the element "#terms" should be checked
|
|
226
|
+
Then the element "#newsletter" should not be checked
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### Element Value
|
|
230
|
+
|
|
231
|
+
```gherkin
|
|
232
|
+
Then the element "#email" should have value "test@example.com"
|
|
233
|
+
Then the element "#quantity" should have value "5"
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### Wait for State Change
|
|
237
|
+
|
|
238
|
+
```gherkin
|
|
239
|
+
Then I verify that "first" element with "text" "Loading" becomes "hidden" during "5" seconds
|
|
240
|
+
Then I verify that "first" element with "test ID" "result" becomes "visible" during "3" seconds
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
## Modal/Dialog Patterns
|
|
244
|
+
|
|
245
|
+
### Modal Interaction
|
|
246
|
+
|
|
247
|
+
```gherkin
|
|
248
|
+
@ui
|
|
249
|
+
Scenario: Confirm deletion in modal
|
|
250
|
+
Given I navigate to "/items"
|
|
251
|
+
When I click the button "Delete"
|
|
252
|
+
Then I should see a modal dialog
|
|
253
|
+
And I should see text "Are you sure?"
|
|
254
|
+
When I click the button "Confirm"
|
|
255
|
+
Then I should not see a modal dialog
|
|
256
|
+
And I should see text "Item deleted"
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
### Cancel Modal
|
|
260
|
+
|
|
261
|
+
```gherkin
|
|
262
|
+
@ui
|
|
263
|
+
Scenario: Cancel modal
|
|
264
|
+
Given I navigate to "/items"
|
|
265
|
+
When I click the button "Delete"
|
|
266
|
+
Then I should see a modal dialog
|
|
267
|
+
When I click the button "Cancel"
|
|
268
|
+
Then I should not see a modal dialog
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
## Tab/Navigation Patterns
|
|
272
|
+
|
|
273
|
+
### Tab Interaction
|
|
274
|
+
|
|
275
|
+
```gherkin
|
|
276
|
+
@ui
|
|
277
|
+
Scenario: Switch between tabs
|
|
278
|
+
Given I navigate to "/settings"
|
|
279
|
+
Then the "General" tab should be active
|
|
280
|
+
When I click the "Security" tab
|
|
281
|
+
Then the "Security" tab should be active
|
|
282
|
+
And I should see text "Password Settings"
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### Sidebar Navigation
|
|
286
|
+
|
|
287
|
+
```gherkin
|
|
288
|
+
@ui
|
|
289
|
+
Scenario: Sidebar navigation
|
|
290
|
+
Given I navigate to "/app"
|
|
291
|
+
Then the sidebar should be visible
|
|
292
|
+
When I click the link "Reports"
|
|
293
|
+
Then the URL should contain "/reports"
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
## Responsive Testing
|
|
297
|
+
|
|
298
|
+
### Test Mobile View
|
|
299
|
+
|
|
300
|
+
```gherkin
|
|
301
|
+
@ui
|
|
302
|
+
Scenario: Mobile navigation
|
|
303
|
+
Given the viewport is "mobile" size
|
|
304
|
+
Given I navigate to "/home"
|
|
305
|
+
Then the sidebar should be hidden
|
|
306
|
+
When I click the button "Menu"
|
|
307
|
+
Then the sidebar should be visible
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
### Test Custom Viewport
|
|
311
|
+
|
|
312
|
+
```gherkin
|
|
313
|
+
@ui
|
|
314
|
+
Scenario: Test at specific resolution
|
|
315
|
+
Given the viewport is 1920x1080
|
|
316
|
+
Given I navigate to "/dashboard"
|
|
317
|
+
Then I should see a split view layout
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
## Wait Patterns
|
|
321
|
+
|
|
322
|
+
### Fixed Wait
|
|
323
|
+
|
|
324
|
+
```gherkin
|
|
325
|
+
When I click the button "Submit"
|
|
326
|
+
Then I wait "2" seconds
|
|
327
|
+
Then I should see text "Success"
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
### Wait for Page Load
|
|
331
|
+
|
|
332
|
+
```gherkin
|
|
333
|
+
When I click the link "Heavy Page"
|
|
334
|
+
Then I wait for the page to load
|
|
335
|
+
Then I should see text "Content Loaded"
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
## Debug Patterns
|
|
339
|
+
|
|
340
|
+
### Pause for Manual Inspection
|
|
341
|
+
|
|
342
|
+
```gherkin
|
|
343
|
+
When I pause for debugging
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
### Take Screenshot
|
|
347
|
+
|
|
348
|
+
```gherkin
|
|
349
|
+
When I save a screenshot as "login-page"
|
|
350
|
+
When I save a full page screenshot as "dashboard-full"
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
### Log Information
|
|
354
|
+
|
|
355
|
+
```gherkin
|
|
356
|
+
Then I log the current URL
|
|
357
|
+
Then I log the page title
|
|
358
|
+
Then I print visible text
|
|
359
|
+
Then I log all cookies
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
## Complete Example: E-commerce Checkout
|
|
363
|
+
|
|
364
|
+
```gherkin
|
|
365
|
+
@ui
|
|
366
|
+
Feature: Checkout Flow
|
|
367
|
+
As a customer
|
|
368
|
+
I want to complete checkout
|
|
369
|
+
So that I can purchase products
|
|
370
|
+
|
|
371
|
+
Background:
|
|
372
|
+
Given I am authenticated in UI as "customer"
|
|
373
|
+
|
|
374
|
+
Scenario: Complete checkout process
|
|
375
|
+
# Add item to cart
|
|
376
|
+
Given I navigate to "/products/widget-123"
|
|
377
|
+
When I select "2" from dropdown "Quantity"
|
|
378
|
+
And I click the button "Add to Cart"
|
|
379
|
+
Then I should see text "Added to cart"
|
|
380
|
+
|
|
381
|
+
# Go to cart
|
|
382
|
+
When I click the link "Cart"
|
|
383
|
+
Then I should see text "Shopping Cart"
|
|
384
|
+
And I should see text "Widget"
|
|
385
|
+
And I should see text "Qty: 2"
|
|
386
|
+
|
|
387
|
+
# Proceed to checkout
|
|
388
|
+
When I click the button "Checkout"
|
|
389
|
+
Then I should see text "Shipping Information"
|
|
390
|
+
|
|
391
|
+
# Fill shipping info
|
|
392
|
+
When I fill the form:
|
|
393
|
+
| Field | Value |
|
|
394
|
+
| Address | 123 Main St |
|
|
395
|
+
| City | Springfield |
|
|
396
|
+
| Zip | 12345 |
|
|
397
|
+
And I click the button "Continue"
|
|
398
|
+
Then I should see text "Payment Information"
|
|
399
|
+
|
|
400
|
+
# Fill payment info
|
|
401
|
+
When I fill in "Card Number" with "4111111111111111"
|
|
402
|
+
And I fill in "Expiry" with "12/25"
|
|
403
|
+
And I fill in "CVV" with "123"
|
|
404
|
+
And I click the button "Place Order"
|
|
405
|
+
|
|
406
|
+
# Confirm order
|
|
407
|
+
Then I should see text "Order Confirmed"
|
|
408
|
+
And the URL should contain "/order-confirmation"
|
|
409
|
+
|
|
410
|
+
Scenario: Apply discount code
|
|
411
|
+
Given I navigate to "/cart"
|
|
412
|
+
When I fill in "Discount Code" with "SAVE20"
|
|
413
|
+
And I click the button "Apply"
|
|
414
|
+
Then I should see text "20% discount applied"
|
|
415
|
+
```
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: katalyst-bdd-quickstart
|
|
3
|
+
description: Get started with the Katalyst BDD testing framework. Use when setting up a new test project, scaffolding tests, configuring environment variables, understanding project structure, or running tests for the first time. Triggers on "set up tests", "install katalyst-xspec", "create test project", "configure BDD", "how to run tests".
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Katalyst BDD Quick Start Guide
|
|
7
|
+
|
|
8
|
+
This skill helps you get started with the @esimplicitylabs/katalyst-xspec BDD testing framework.
|
|
9
|
+
|
|
10
|
+
## Step 1: Scaffold a New Project
|
|
11
|
+
|
|
12
|
+
Run the scaffolding command:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npx @esimplicitylabs/katalyst-xspec init
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Options:
|
|
19
|
+
- `--dir <name>` - Create in specific directory
|
|
20
|
+
- `--force` - Overwrite existing files
|
|
21
|
+
|
|
22
|
+
Example:
|
|
23
|
+
```bash
|
|
24
|
+
npx @esimplicitylabs/katalyst-xspec init --dir my-tests
|
|
25
|
+
cd my-tests
|
|
26
|
+
npm install
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Step 2: Understand the Project Structure
|
|
30
|
+
|
|
31
|
+
The scaffold creates:
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
my-tests/
|
|
35
|
+
├── features/
|
|
36
|
+
│ ├── api/
|
|
37
|
+
│ │ └── 00_api_examples.feature # API test examples
|
|
38
|
+
│ ├── ui/
|
|
39
|
+
│ │ └── 00_ui_examples.feature # UI test examples
|
|
40
|
+
│ ├── hybrid/
|
|
41
|
+
│ │ └── 00_hybrid_examples.feature # Combined API+UI tests
|
|
42
|
+
│ ├── tui/
|
|
43
|
+
│ │ └── 00_tui_examples.feature # Terminal UI tests
|
|
44
|
+
│ └── steps/
|
|
45
|
+
│ ├── fixtures.ts # Adapter configuration
|
|
46
|
+
│ └── steps.ts # Step registration
|
|
47
|
+
├── playwright.config.ts # BDD project config
|
|
48
|
+
├── .env.example # Environment template
|
|
49
|
+
├── tsconfig.json # TypeScript config
|
|
50
|
+
└── package.json # Dependencies
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Key Files
|
|
54
|
+
|
|
55
|
+
**`features/steps/fixtures.ts`** - Configures adapters:
|
|
56
|
+
```typescript
|
|
57
|
+
import { createBddTest } from '@esimplicitylabs/katalyst-xspec';
|
|
58
|
+
|
|
59
|
+
export const test = createBddTest({
|
|
60
|
+
// Default adapters are used unless you customize
|
|
61
|
+
});
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
**`features/steps/steps.ts`** - Registers step definitions:
|
|
65
|
+
```typescript
|
|
66
|
+
import { test } from './fixtures';
|
|
67
|
+
import { registerAllSteps } from '@esimplicitylabs/katalyst-xspec/steps';
|
|
68
|
+
|
|
69
|
+
registerAllSteps(test);
|
|
70
|
+
|
|
71
|
+
export { test };
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
**`playwright.config.ts`** - Defines BDD projects:
|
|
75
|
+
```typescript
|
|
76
|
+
import { defineBddProject } from 'playwright-bdd';
|
|
77
|
+
|
|
78
|
+
const apiBdd = defineBddProject({
|
|
79
|
+
name: 'api',
|
|
80
|
+
features: 'features/api/**/*.feature',
|
|
81
|
+
steps: 'features/steps/**/*.ts',
|
|
82
|
+
tags: '@api',
|
|
83
|
+
});
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Step 3: Configure Environment
|
|
87
|
+
|
|
88
|
+
Copy the environment template:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
cp .env.example .env
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Edit `.env` with your settings:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
# API Configuration
|
|
98
|
+
API_BASE_URL=http://localhost:3000
|
|
99
|
+
|
|
100
|
+
# Authentication (required -- no hardcoded defaults)
|
|
101
|
+
DEFAULT_ADMIN_USERNAME=admin@example.com
|
|
102
|
+
DEFAULT_ADMIN_PASSWORD=admin123
|
|
103
|
+
DEFAULT_USER_USERNAME=user@example.com
|
|
104
|
+
DEFAULT_USER_PASSWORD=user123
|
|
105
|
+
API_AUTH_LOGIN_PATH=/auth/login
|
|
106
|
+
|
|
107
|
+
# UI Configuration
|
|
108
|
+
FRONTEND_URL=http://localhost:3000
|
|
109
|
+
BASE_URL=http://localhost:3000
|
|
110
|
+
HEADLESS=true
|
|
111
|
+
|
|
112
|
+
# Cleanup Rules (required -- no built-in rules)
|
|
113
|
+
# CLEANUP_RULES='[{"varMatch":"user","path":"/api/users/{id}"}]'
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Required Variables by Test Type
|
|
117
|
+
|
|
118
|
+
| Test Type | Required Variables |
|
|
119
|
+
|-----------|-------------------|
|
|
120
|
+
| `@api` | `API_BASE_URL` |
|
|
121
|
+
| `@ui` | `FRONTEND_URL` or `BASE_URL` |
|
|
122
|
+
| `@hybrid` | Both API and UI variables |
|
|
123
|
+
| Auth steps | `DEFAULT_*_USERNAME`, `DEFAULT_*_PASSWORD` |
|
|
124
|
+
|
|
125
|
+
## Step 4: Write Your First Test
|
|
126
|
+
|
|
127
|
+
### API Test
|
|
128
|
+
|
|
129
|
+
Create `features/api/health.feature`:
|
|
130
|
+
|
|
131
|
+
```gherkin
|
|
132
|
+
@api
|
|
133
|
+
Feature: Health Check
|
|
134
|
+
|
|
135
|
+
Scenario: API is healthy
|
|
136
|
+
When I GET "/health"
|
|
137
|
+
Then the response status should be 200
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### UI Test
|
|
141
|
+
|
|
142
|
+
Create `features/ui/home.feature`:
|
|
143
|
+
|
|
144
|
+
```gherkin
|
|
145
|
+
@ui
|
|
146
|
+
Feature: Home Page
|
|
147
|
+
|
|
148
|
+
Scenario: Home page loads
|
|
149
|
+
Given I navigate to "/"
|
|
150
|
+
Then I should see text "Welcome"
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Hybrid Test
|
|
154
|
+
|
|
155
|
+
Create `features/hybrid/workflow.feature`:
|
|
156
|
+
|
|
157
|
+
```gherkin
|
|
158
|
+
@hybrid
|
|
159
|
+
Feature: User Workflow
|
|
160
|
+
|
|
161
|
+
Scenario: Create via API, verify in UI
|
|
162
|
+
Given I am authenticated as an admin via API
|
|
163
|
+
When I POST "/users" with JSON body:
|
|
164
|
+
"""
|
|
165
|
+
{ "name": "Test User" }
|
|
166
|
+
"""
|
|
167
|
+
Then the response status should be 201
|
|
168
|
+
And I store the value at "id" as "userId"
|
|
169
|
+
|
|
170
|
+
Given I navigate to "/users/{userId}"
|
|
171
|
+
Then I should see text "Test User"
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## Step 5: Run Tests
|
|
175
|
+
|
|
176
|
+
**IMPORTANT:** You must generate Playwright tests before running.
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
# 1. Generate tests from feature files (REQUIRED)
|
|
180
|
+
npm run gen
|
|
181
|
+
|
|
182
|
+
# 2. Run all tests
|
|
183
|
+
npm test
|
|
184
|
+
|
|
185
|
+
# 3. Run specific project
|
|
186
|
+
npx playwright test --project=api
|
|
187
|
+
npx playwright test --project=ui
|
|
188
|
+
npx playwright test --project=hybrid
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### Common Run Commands
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
# Run with specific tag
|
|
195
|
+
npx playwright test --grep "@smoke"
|
|
196
|
+
|
|
197
|
+
# Run single feature file
|
|
198
|
+
npx playwright test features/api/users.feature
|
|
199
|
+
|
|
200
|
+
# Debug mode (opens browser and pauses)
|
|
201
|
+
npx playwright test --debug
|
|
202
|
+
|
|
203
|
+
# UI mode (interactive test runner)
|
|
204
|
+
npx playwright test --ui
|
|
205
|
+
|
|
206
|
+
# Headed mode (see the browser)
|
|
207
|
+
npx playwright test --headed
|
|
208
|
+
|
|
209
|
+
# Run with verbose output
|
|
210
|
+
npx playwright test --reporter=list
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
## Step 6: View Results
|
|
214
|
+
|
|
215
|
+
After running tests, find reports at:
|
|
216
|
+
|
|
217
|
+
| Report | Location |
|
|
218
|
+
|--------|----------|
|
|
219
|
+
| Cucumber HTML | `cucumber-report/index.html` |
|
|
220
|
+
| Cucumber JSON | `cucumber-report/report.json` |
|
|
221
|
+
| Playwright HTML | `playwright-report/index.html` |
|
|
222
|
+
|
|
223
|
+
Open the Playwright report:
|
|
224
|
+
```bash
|
|
225
|
+
npx playwright show-report
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
## Common Tags
|
|
229
|
+
|
|
230
|
+
| Tag | Purpose |
|
|
231
|
+
|-----|---------|
|
|
232
|
+
| `@api` | API-only tests |
|
|
233
|
+
| `@ui` | UI-only tests |
|
|
234
|
+
| `@tui` | Terminal UI tests |
|
|
235
|
+
| `@hybrid` | Combined API+UI tests |
|
|
236
|
+
| `@smoke` | Quick smoke tests |
|
|
237
|
+
| `@Skip` | Skip this scenario |
|
|
238
|
+
| `@wip` | Work in progress |
|
|
239
|
+
|
|
240
|
+
## Quick Reference: Essential Steps
|
|
241
|
+
|
|
242
|
+
### API Steps
|
|
243
|
+
```gherkin
|
|
244
|
+
When I GET "/endpoint"
|
|
245
|
+
When I POST "/endpoint" with JSON body:
|
|
246
|
+
Then the response status should be 200
|
|
247
|
+
And I store the value at "id" as "userId"
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
### UI Steps
|
|
251
|
+
```gherkin
|
|
252
|
+
Given I navigate to "/page"
|
|
253
|
+
When I click the button "Submit"
|
|
254
|
+
When I fill in "Email" with "test@example.com"
|
|
255
|
+
Then I should see text "Success"
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
### Shared Steps
|
|
259
|
+
```gherkin
|
|
260
|
+
Given I generate a UUID and store as "runId"
|
|
261
|
+
Given I set variable "name" to "value"
|
|
262
|
+
Given I register cleanup DELETE "/resource/{id}"
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
## Troubleshooting Quick Fixes
|
|
266
|
+
|
|
267
|
+
| Issue | Solution |
|
|
268
|
+
|-------|----------|
|
|
269
|
+
| "No tests found" | Run `npm run gen` first |
|
|
270
|
+
| Steps not available | Check you have the correct tag |
|
|
271
|
+
| Auth fails | Verify `.env` credentials |
|
|
272
|
+
| Can't find element | Use `When I pause for debugging` |
|
|
273
|
+
|
|
274
|
+
## Next Steps
|
|
275
|
+
|
|
276
|
+
1. **Create more tests** - Add feature files to `features/api/`, `features/ui/`, etc.
|
|
277
|
+
2. **Learn steps** - See full step reference with `katalyst-bdd-step-reference` skill
|
|
278
|
+
3. **Patterns** - Learn test patterns with `katalyst-bdd-create-test` skill
|
|
279
|
+
4. **Custom adapters** - Extend framework with `katalyst-bdd-architecture` skill
|
|
280
|
+
|
|
281
|
+
## Upgrade Existing Project
|
|
282
|
+
|
|
283
|
+
To upgrade an existing project to the latest version:
|
|
284
|
+
|
|
285
|
+
```bash
|
|
286
|
+
npx @esimplicitylabs/katalyst-xspec upgrade
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
This updates:
|
|
290
|
+
- Package dependencies
|
|
291
|
+
- Configuration templates
|
|
292
|
+
- Step definitions
|