Skip to content

feat(testing): live-stack test harness — deploy/assert/destroy per suite, emulator-aware #1224

Closed

Description

@lex00

Filed for review. Scope and approach not yet confirmed.

A user-facing test harness for stacks: deploy a real instance once per suite, run assertions against the live resources, tear it down — emulator-locally, real-cloud in CI.

Finding

@intentius/chant-test-utils serves chant's own development (mock entities, describeExample), not chant users. A project consuming chant has no supported way to write "deploy my stack, assert against it, destroy it" as a vitest suite. The pieces exist: local executor runs ApplyOp with no server, environments entries carry an endpoint for emulator targeting, chant emulator up (#920) boots emulators, and observation reads back live state.

Want

1. Suite-scoped lifecycle helpers

Exported from test-utils (or a new subpath @intentius/chant/testing):

const stack = await deployStack({ dir: ".", env: "test-<suite>", params: {...} });
// stack.outputs, stack.entities, stack.env
await stack.assertLive("uploads");     // observation-backed existence/status check
await stack.destroy();                 // marker-scoped teardown of the suite env

deployStack = build (env-scoped names, #1221) + additive local-executor apply; destroy = #1222's teardown. One deploy per suite (beforeAll/afterAll), not per test.

2. Isolation

Default env name derives from suite + a run nonce so parallel CI jobs don't collide; document --env-override for shared long-lived test envs.

3. Emulator-aware by default

When the target env declares an endpoint (or chant emulator up --json env is applied), the same suite runs creds-free against Floci/floci-az/floci-gcp/flaps. CI can point the identical suite at a real account.

Acceptance

  • A worked example under one lexicon's examples: suite deploys, asserts an output and a live resource attribute, destroys; green against the emulator in a Docker-gated test.
  • Teardown runs in afterAll even when assertions fail; a crashed suite's env is recoverable by rerunning destroy (stateless, marker-scoped).
  • Docs page (local-testing section) covering the harness, isolation naming, and the emulator/real-cloud switch.
  • No Temporal dependency; local executor only.

Depends on #1221, #1222; composes with #920.

Activity

  1. added
    enhancement
    needs-review
    on Jul 30, 2026
  2. added
    area:core
    on Aug 23, 2026
  3. lex00 commented on Aug 24, 2026

    @lex00
    ContributorAuthor

    Scope confirmed (build, modified). Verified against current code.

    Premise updates: runOpLocally is already exported from @intentius/chant/op and core's export map supports subpaths, so the harness is a thin composition layer, not new machinery. environments: [{name, endpoint}] + environmentEndpoint() (#1166) and chant emulator up --json (#920, widened by #1368) provide the emulator switch as filed. test-utils stays private: true.

    V1 = a @intentius/chant/testing subpath in core exporting deployStack({ dir, env?, params? }) — programmatic build (config resolution mirrored from example-harness) + additive ApplyOp via runOpLocally, returning { outputs, entities, env, destroy } — with destroy() delegating in-process to #1222's marker sweep. Default env = suite name + run nonce. Emulator-aware via declared endpoints / emulator env. One worked AWS+Floci example suite, Docker-gated, teardown in afterAll surviving assertion failure; crashed-suite recovery = rerun destroy (stateless by #1222's design). Docs page under local-testing/.

    Out (v1): assertLive as a rich API (follow-up issue; at most an observation-backed existence check for AWS), multi-lexicon example parity, Temporal path, a chant test CLI verb.

    Blocked on: #1221 (same dynamic-env legality contract as #1223's pr-*, plus envName() for collision-free physical names) and #1222 (teardown exported as a function, holes surfaced as failures).

    Plan: PR A @intentius/chant/testing + unit tests vs mock plugin; PR B worked AWS/Floci example suite + just target; PR C docs page; follow-up issue for assertLive.

  4. removed
    needs-review
    on Aug 24, 2026
  5. lex00 commented on Aug 24, 2026

    @lex00
    ContributorAuthor

    Shipped: #1853 (@intentius/chant/testing deployStack/destroy), #1858 (worked Floci example + Docker-gated suite, absorbing #1856's docs page). assertLive follow-up: #1857.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:coreenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions