@glubean/cli 0.2.5 → 0.3.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 +22 -2
- package/dist/commands/contracts.d.ts.map +1 -1
- package/dist/commands/contracts.js +28 -4
- package/dist/commands/contracts.js.map +1 -1
- package/dist/commands/init.d.ts +2 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +267 -60
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/migrate.d.ts +31 -0
- package/dist/commands/migrate.d.ts.map +1 -0
- package/dist/commands/migrate.js +516 -0
- package/dist/commands/migrate.js.map +1 -0
- package/dist/commands/redact.d.ts.map +1 -1
- package/dist/commands/redact.js +32 -8
- package/dist/commands/redact.js.map +1 -1
- package/dist/commands/run.d.ts +110 -2
- package/dist/commands/run.d.ts.map +1 -1
- package/dist/commands/run.js +493 -43
- package/dist/commands/run.js.map +1 -1
- package/dist/lib/config.d.ts +267 -43
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +744 -149
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/env.d.ts +29 -0
- package/dist/lib/env.d.ts.map +1 -0
- package/dist/lib/env.js +59 -0
- package/dist/lib/env.js.map +1 -0
- package/dist/lib/print-plan.d.ts +21 -0
- package/dist/lib/print-plan.d.ts.map +1 -0
- package/dist/lib/print-plan.js +108 -0
- package/dist/lib/print-plan.js.map +1 -0
- package/dist/lib/upload.d.ts +36 -1
- package/dist/lib/upload.d.ts.map +1 -1
- package/dist/lib/upload.js +126 -19
- package/dist/lib/upload.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +420 -27
- package/dist/main.js.map +1 -1
- package/package.json +15 -6
- package/templates/README.md +7 -13
- package/templates/demo/.env.example +7 -0
- package/templates/demo/.env.secrets.example +11 -0
- package/templates/demo/README.md +60 -0
- package/templates/demo/config/api.ts +24 -0
- package/templates/demo/gitignore.tpl +13 -0
- package/templates/demo/glubean.yaml +48 -0
- package/templates/demo/tests/api-flaky/search-flaky.test.ts +28 -0
- package/templates/demo/tests/api-stable/get-users.test.ts +30 -0
- package/templates/demo/tests/canary/synthetic-50pct-flaky.test.ts +23 -0
- package/templates/demo/tests/contracts/stable/users-contract.contract.ts +70 -0
- package/templates/demo/tsconfig.json +15 -0
- package/templates/AI-INSTRUCTIONS.md +0 -160
- package/templates/ci-config/ci.yaml +0 -13
- package/templates/ci-config/default.yaml +0 -9
- package/templates/ci-config/explore.yaml +0 -5
- package/templates/ci-config/staging.yaml +0 -9
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
# Glubean Test Project
|
|
2
|
-
|
|
3
|
-
API test automation project using `@glubean/sdk`. Runtime is **Node.js**. Packages are from **npm**.
|
|
4
|
-
|
|
5
|
-
## Project Structure
|
|
6
|
-
|
|
7
|
-
```
|
|
8
|
-
tests/ # Permanent test files — run in CI and Cloud
|
|
9
|
-
explore/ # Exploratory tests — quick iteration in your editor
|
|
10
|
-
data/ # Test data files (JSON, CSV, YAML)
|
|
11
|
-
context/ # API specs and reference docs for AI and tooling
|
|
12
|
-
.env # Public variables (BASE_URL)
|
|
13
|
-
.env.secrets # Credentials — gitignored
|
|
14
|
-
package.json # Runtime config, dependencies, glubean settings
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
## Setup
|
|
18
|
-
|
|
19
|
-
If `glubean run` fails with module-not-found errors, run:
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
npm install
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
## BEFORE Writing or Modifying Any Test (MANDATORY)
|
|
26
|
-
|
|
27
|
-
You MUST complete these steps before writing any test code. Do NOT skip this — not even for "simple" tests.
|
|
28
|
-
|
|
29
|
-
1. Search `context/` for the API you are testing. Check OpenAPI specs (`context/*.json`) for exact paths, methods,
|
|
30
|
-
request/response schemas. **Do NOT guess endpoint paths or response shapes.**
|
|
31
|
-
2. Check `.glubean/docs/` exists. If missing, download:
|
|
32
|
-
```bash
|
|
33
|
-
mkdir -p .glubean/docs
|
|
34
|
-
curl -sL https://raw.githubusercontent.com/glubean/cheatsheet/main/sdk-reference.md -o .glubean/docs/sdk-reference.md
|
|
35
|
-
curl -sL https://raw.githubusercontent.com/glubean/cheatsheet/main/patterns.md -o .glubean/docs/patterns.md
|
|
36
|
-
curl -sL https://raw.githubusercontent.com/glubean/cheatsheet/main/cli-reference.md -o .glubean/docs/cli-reference.md
|
|
37
|
-
```
|
|
38
|
-
3. Read `.glubean/docs/sdk-reference.md` — all exports, signatures, options.
|
|
39
|
-
4. Read `.glubean/docs/patterns.md` — runnable examples for every test type.
|
|
40
|
-
5. THEN write the test using only patterns from those docs and API details from step 1.
|
|
41
|
-
|
|
42
|
-
**If you write test code without completing steps 1-4, you are violating this rule.** Do NOT guess — the endpoint paths,
|
|
43
|
-
response schemas, and SDK API are all documented.
|
|
44
|
-
|
|
45
|
-
**If `context/` has no spec or docs for the API under test:** Unless it is a well-known public API (e.g. GitHub,
|
|
46
|
-
Stripe), STOP and ask the user for the endpoint path, method, and response schema. Do NOT hallucinate paths or response
|
|
47
|
-
shapes.
|
|
48
|
-
|
|
49
|
-
**If the OpenAPI spec exists but lacks response schemas:** Warn the user that response structure will be inferred at
|
|
50
|
-
runtime, which lowers first-pass accuracy. Suggest adding response examples to `context/` to enable one-shot test
|
|
51
|
-
generation.
|
|
52
|
-
|
|
53
|
-
## Quick Checklist
|
|
54
|
-
|
|
55
|
-
Before submitting any test, verify:
|
|
56
|
-
|
|
57
|
-
- [ ] Checked `context/` for endpoint spec + response schema
|
|
58
|
-
- [ ] Response schema available? If not, warned user about reduced accuracy
|
|
59
|
-
- [ ] Test ID is kebab-case and unique across the project
|
|
60
|
-
- [ ] Tags are set (e.g. `["api"]`, `["smoke"]`, `["e2e"]`)
|
|
61
|
-
- [ ] Creates resources → has `.teardown()` cleanup
|
|
62
|
-
- [ ] No hardcoded secrets or test data in the test file
|
|
63
|
-
|
|
64
|
-
## Coverage Expectations
|
|
65
|
-
|
|
66
|
-
Do not stop at a single happy-path test unless the user explicitly asks for only one case.
|
|
67
|
-
|
|
68
|
-
- For authentication/identity endpoints, include:
|
|
69
|
-
- one authenticated success case
|
|
70
|
-
- one unauthenticated or invalid-credential case
|
|
71
|
-
- For protected resources, include authorization failure cases (`401` or `403`) when applicable.
|
|
72
|
-
- For create/update endpoints, include at least one invalid-input case when the contract documents validation rules.
|
|
73
|
-
- If the OpenAPI spec lacks enough detail for a negative case, say so explicitly and choose the safest verifiable case.
|
|
74
|
-
|
|
75
|
-
## Definition of Done for API Tests
|
|
76
|
-
|
|
77
|
-
Before considering an API test complete, verify whether the endpoint has:
|
|
78
|
-
|
|
79
|
-
- a success path
|
|
80
|
-
- an auth boundary
|
|
81
|
-
- a validation boundary
|
|
82
|
-
- a not-found or forbidden boundary
|
|
83
|
-
|
|
84
|
-
Cover all applicable boundaries unless the user asked for a narrower scope.
|
|
85
|
-
|
|
86
|
-
## Import Convention
|
|
87
|
-
|
|
88
|
-
Always use the npm package name:
|
|
89
|
-
|
|
90
|
-
```typescript
|
|
91
|
-
// Correct
|
|
92
|
-
import { test } from "@glubean/sdk";
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
## Conventions
|
|
96
|
-
|
|
97
|
-
- **One test export per behavior.** Each `export const` is a test case.
|
|
98
|
-
- **Tags:** `["smoke"]` for health checks, `["api"]` for API tests, `["e2e"]` for browser tests.
|
|
99
|
-
- **IDs:** kebab-case, unique across the project. Used for history tracking.
|
|
100
|
-
- **Data separation:** keep test data in `data/`, never hardcode payloads in test files.
|
|
101
|
-
- **Secrets:** use `secrets.require("KEY")` or configure's secret binding. Never hardcode credentials.
|
|
102
|
-
- **Cleanup:** use `.teardown()` for any resource created during the test.
|
|
103
|
-
- **Imports:** use `.ts` extensions for local files.
|
|
104
|
-
|
|
105
|
-
## Running Tests
|
|
106
|
-
|
|
107
|
-
```bash
|
|
108
|
-
glubean run # Run all tests in tests/
|
|
109
|
-
glubean run tests/ # Run a specific directory
|
|
110
|
-
glubean run --filter smoke # Run by tag
|
|
111
|
-
glubean run --explore # Run explore/ tests
|
|
112
|
-
glubean run --upload # Run and upload results to Cloud
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
For all CLI options, run `glubean --help` or `glubean run --help`.
|
|
116
|
-
|
|
117
|
-
## MCP Setup (enables AI closed-loop)
|
|
118
|
-
|
|
119
|
-
Without MCP, the AI can only write tests. With MCP, the AI can: **write → run → read failures → fix → rerun → pass** —
|
|
120
|
-
without human intervention.
|
|
121
|
-
|
|
122
|
-
### Claude Code
|
|
123
|
-
|
|
124
|
-
```bash
|
|
125
|
-
claude mcp add glubean -- npx @glubean/mcp
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
### Cursor
|
|
129
|
-
|
|
130
|
-
Add to `~/.cursor/mcp.json`:
|
|
131
|
-
|
|
132
|
-
```json
|
|
133
|
-
{
|
|
134
|
-
"mcpServers": {
|
|
135
|
-
"glubean": {
|
|
136
|
-
"command": "npx",
|
|
137
|
-
"args": ["@glubean/mcp"]
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
### Available MCP Tools
|
|
144
|
-
|
|
145
|
-
- `glubean_run_local_file` — run a test file locally, returns structured results (assertions, logs, traces)
|
|
146
|
-
- `glubean_discover_tests` — scan a file and return test export metadata (id, name, tags)
|
|
147
|
-
- `glubean_list_test_files` — list all test files in the project
|
|
148
|
-
- `glubean_diagnose_config` — check project config for common issues (.env, package.json, dirs)
|
|
149
|
-
- `glubean_get_last_run_summary` — get summary of the most recent local run
|
|
150
|
-
- `glubean_get_local_events` — get filtered events (assertions, logs, traces) from the last run; useful for debugging
|
|
151
|
-
failures
|
|
152
|
-
|
|
153
|
-
## Type Definitions
|
|
154
|
-
|
|
155
|
-
For full API details beyond the cheatsheet, go to the import source:
|
|
156
|
-
|
|
157
|
-
```typescript
|
|
158
|
-
import { configure, fromDir, test } from "@glubean/sdk";
|
|
159
|
-
// Go-to-definition on these for exact signatures and options
|
|
160
|
-
```
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
# CI run config — used by: npm run test:ci
|
|
2
|
-
# Optimized for CI pipelines: fail fast, structured output, no pretty-print
|
|
3
|
-
run:
|
|
4
|
-
testDir: ./tests
|
|
5
|
-
failFast: true
|
|
6
|
-
pretty: false
|
|
7
|
-
# Emit full HTTP trace in results (useful for debugging CI failures)
|
|
8
|
-
emitFullTrace: false
|
|
9
|
-
# Stop after N failures (uncomment to enable)
|
|
10
|
-
# failAfter: 5
|
|
11
|
-
|
|
12
|
-
redaction:
|
|
13
|
-
replacementFormat: simple
|