@elench/testkit 0.1.10 → 0.1.11
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 +24 -30
- package/lib/cli.mjs +18 -3
- package/lib/config.mjs +264 -176
- package/lib/runner.mjs +488 -375
- package/package.json +4 -3
- package/infra/fly-app-ensure.sh +0 -23
- package/infra/fly-build.sh +0 -55
- package/infra/fly-destroy.sh +0 -21
- package/infra/fly-down.sh +0 -19
- package/infra/fly-up.sh +0 -142
package/README.md
CHANGED
|
@@ -1,44 +1,36 @@
|
|
|
1
1
|
# @elench/testkit
|
|
2
2
|
|
|
3
|
-
CLI that reads `
|
|
3
|
+
CLI that reads `runner.manifest.json` plus `testkit.config.json` from a product repo, starts the required local services, provisions Neon branches when configured, and runs manifest-defined suites across `k6` and Playwright.
|
|
4
4
|
|
|
5
5
|
## Prerequisites
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
8
|
sudo snap install k6
|
|
9
9
|
sudo apt-get install -y jq
|
|
10
|
-
curl -L https://fly.io/install.sh | sh
|
|
11
|
-
fly auth login
|
|
12
10
|
```
|
|
13
11
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
Add platform secrets to each product's `.env`:
|
|
17
|
-
|
|
18
|
-
```bash
|
|
19
|
-
NEON_API_KEY='...'
|
|
20
|
-
FLY_API_TOKEN='...'
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
Product secrets (`CLERK_SECRET_KEY`, etc.) are also loaded from the same `.env`.
|
|
12
|
+
For DAL suites, `@elench/testkit` ships its own `k6` SQL binary. For suites using a Neon branch, set `NEON_API_KEY` in the product `.env`, shell, or `.envrc`.
|
|
24
13
|
|
|
25
14
|
## Usage
|
|
26
15
|
|
|
27
16
|
```bash
|
|
28
17
|
cd bourne
|
|
29
18
|
|
|
30
|
-
# Run
|
|
19
|
+
# Run every testkit-managed suite
|
|
31
20
|
npx @elench/testkit
|
|
32
21
|
|
|
33
|
-
#
|
|
34
|
-
npx @elench/testkit int
|
|
22
|
+
# Filter by type
|
|
23
|
+
npx @elench/testkit int
|
|
24
|
+
npx @elench/testkit dal
|
|
35
25
|
npx @elench/testkit e2e
|
|
36
26
|
|
|
37
|
-
#
|
|
38
|
-
npx @elench/testkit
|
|
27
|
+
# Filter by framework
|
|
28
|
+
npx @elench/testkit --framework playwright
|
|
29
|
+
npx @elench/testkit --framework k6
|
|
39
30
|
|
|
40
|
-
#
|
|
41
|
-
npx @elench/testkit
|
|
31
|
+
# Specific service / suite
|
|
32
|
+
npx @elench/testkit frontend e2e -s auth
|
|
33
|
+
npx @elench/testkit bourne int -s health
|
|
42
34
|
|
|
43
35
|
# Lifecycle
|
|
44
36
|
npx @elench/testkit status
|
|
@@ -47,17 +39,19 @@ npx @elench/testkit destroy
|
|
|
47
39
|
|
|
48
40
|
## How it works
|
|
49
41
|
|
|
50
|
-
1. **
|
|
51
|
-
2. **
|
|
52
|
-
3. **
|
|
53
|
-
4. **
|
|
54
|
-
5. **
|
|
55
|
-
6. **
|
|
42
|
+
1. **Discovery** — reads `runner.manifest.json` for services, suites, files, and frameworks
|
|
43
|
+
2. **Config** — reads `testkit.config.json` for local runtime, migration, dependency, and database settings
|
|
44
|
+
3. **Database** — provisions a Neon branch when a service declares one
|
|
45
|
+
4. **Seed** — runs optional product seed commands against the provisioned database
|
|
46
|
+
5. **Runtime** — starts required local services, waits for readiness, and injects test env
|
|
47
|
+
6. **Execution** — runs `k6` suites file-by-file and Playwright suites suite-by-suite
|
|
48
|
+
7. **Cleanup** — stops local processes and preserves `.testkit/` state for inspection or later destroy
|
|
56
49
|
|
|
57
|
-
|
|
50
|
+
## File roles
|
|
58
51
|
|
|
59
|
-
|
|
52
|
+
- `runner.manifest.json`: canonical test inventory
|
|
53
|
+
- `testkit.config.json`: local execution and provisioning config
|
|
60
54
|
|
|
61
|
-
##
|
|
55
|
+
## Schema
|
|
62
56
|
|
|
63
|
-
See [testkit-
|
|
57
|
+
See [testkit-config-schema.md](testkit-config-schema.md).
|
package/lib/cli.mjs
CHANGED
|
@@ -12,8 +12,10 @@ export function run() {
|
|
|
12
12
|
cli
|
|
13
13
|
.command("[first] [second] [third]", "Run test suites (int, e2e, dal, all)")
|
|
14
14
|
.option("-s, --suite <name>", "Run specific suite(s)", { default: [] })
|
|
15
|
-
.option("--build", "Build image from source first", { default: false })
|
|
16
15
|
.option("--dir <path>", "Explicit product directory")
|
|
16
|
+
.option("--framework <name>", "Filter by framework (k6, playwright, all)", {
|
|
17
|
+
default: "all",
|
|
18
|
+
})
|
|
17
19
|
.action(async (first, second, third, options) => {
|
|
18
20
|
// Resolve: service filter, suite type, and --dir.
|
|
19
21
|
//
|
|
@@ -57,7 +59,14 @@ export function run() {
|
|
|
57
59
|
);
|
|
58
60
|
}
|
|
59
61
|
|
|
60
|
-
const
|
|
62
|
+
const allConfigs = loadConfigs({ dir: options.dir });
|
|
63
|
+
const configs = service
|
|
64
|
+
? allConfigs.filter((config) => config.name === service)
|
|
65
|
+
: allConfigs;
|
|
66
|
+
if (service && configs.length === 0) {
|
|
67
|
+
const available = allConfigs.map((config) => config.name).join(", ");
|
|
68
|
+
throw new Error(`Service "${service}" not found. Available: ${available}`);
|
|
69
|
+
}
|
|
61
70
|
|
|
62
71
|
// Lifecycle commands
|
|
63
72
|
if (type === "status" || type === "destroy") {
|
|
@@ -69,9 +78,15 @@ export function run() {
|
|
|
69
78
|
return;
|
|
70
79
|
}
|
|
71
80
|
|
|
81
|
+
if (!["all", "k6", "playwright"].includes(options.framework)) {
|
|
82
|
+
throw new Error(
|
|
83
|
+
`Unknown framework "${options.framework}". Expected one of: all, k6, playwright.`
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
72
87
|
const suiteType = type || "all";
|
|
73
88
|
const suiteNames = Array.isArray(options.suite) ? options.suite : [options.suite].filter(Boolean);
|
|
74
|
-
await runner.runAll(configs, suiteType, suiteNames, options);
|
|
89
|
+
await runner.runAll(configs, suiteType, suiteNames, options, allConfigs);
|
|
75
90
|
});
|
|
76
91
|
|
|
77
92
|
cli.help();
|