@mechris3/glassbox 0.1.0 → 0.1.1

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 +34 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -141,6 +141,40 @@ export default defineConfig({
141
141
  });
142
142
  ```
143
143
 
144
+ ### Lifecycle Hooks
145
+
146
+ Run code before/after journeys for test data setup and cleanup:
147
+
148
+ ```typescript
149
+ // glassbox.config.ts
150
+ export default defineConfig({
151
+ testData: {
152
+ globalSetup: './helpers/global-setup.ts', // Once before all journeys
153
+ beforeEach: './helpers/before-each.ts', // Before each journey
154
+ afterEach: './helpers/after-each.ts', // After each journey (even on failure)
155
+ globalTeardown: './helpers/global-teardown.ts', // Once after all journeys
156
+ },
157
+ });
158
+ ```
159
+
160
+ Hook files export a default async function:
161
+
162
+ ```typescript
163
+ // helpers/before-each.ts
164
+ import type { HookContext } from '@mechris3/glassbox';
165
+
166
+ export default async function(context: HookContext) {
167
+ // Reset app state before each journey
168
+ await fetch(`${context.targetUrl}/api/test-data/reset`, { method: 'POST' });
169
+ }
170
+ ```
171
+
172
+ The `HookContext` provides:
173
+ - `targetUrl` — the app URL being tested
174
+ - `journeyName` — current journey name (beforeEach/afterEach only)
175
+ - `journeyPath` — current journey file path (beforeEach/afterEach only)
176
+ - `journeyStatus` — 'passed' or 'failed' (afterEach only)
177
+
144
178
  ## CLI Commands
145
179
 
146
180
  Run all commands from the directory containing your `glassbox.config.ts`:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mechris3/glassbox",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Debugger-style browser automation test runner with live execution control via CDP",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",