Docs/Discover and run
#

Discover and run

Discover and run tests

Check the repository locally

Install dependencies and list the tests before they contact an Application:

bash
npm ci
npx playwright test --list --config playwright.config.ts

Playwright --list should import the test files and enumerate their tests, without opening an Application or using a real persona or seed. Local shell commands do not receive Cofactor's runtime-reference placeholders; if your config requires environment variables locally, set harmless dummy values such as BASE_URL=https://example.com, QA_EMAIL=qa@example.com, QA_PASSWORD=placeholder and ACCOUNT_ID=example-account. Keep test imports, module setup and the Playwright config safe to load at list time: make network requests, sign in and use seeded records only inside test execution. During Cofactor preparation, install and discovery receive generated placeholder values for runtime references, never real personas or seed outputs.

Running discovery

The first real suite run performs discovery as part of preparation; there is no separate discovery command or service. Start it without test IDs:

bash
cofactor test-suite run --suite "Example browser tests" --org Acme

Cofactor stores discovered rows before the run's results arrive. A new test first shows as Unverified with zero result counts. Once results are available, cofactor external-run get <run-id> --org Acme shows the run results and stable test IDs. You can then select those IDs for a proof run.

A test's stable identity is based on its source, provider and source-relative file, project and title path. Changing that path by renaming or moving a test creates a new identity. The previous identity and its history remain available. Selecting a test executes its complete connected serial or dependency group when Playwright requires other group members to run together. Group execution does not attach every member automatically: any member with its own complete passing or flaky result can be cited by its stable ID. Explicitly attach each test you want to cite.

Run a pushed Application head

For proof evidence, start with a clean checkout of the pushed Application commit. Record its full commit SHA. Claim the matching Application environment at that SHA, without waiting in the claim command:

bash
cofactor sandbox claim --application Example --environment default \
  --at <pushed-application-sha> --json --org Acme

Save the returned sandbox ID. Inspect your live claims until this one is ready:

bash
cofactor sandbox claims --application Example --org Acme

Then, from the same clean checkout at that pushed commit, sync the claimed Sandbox and build it:

bash
cofactor sandbox sync <sandbox-id> --build --org Acme

Keep the checkout clean and at the claimed commit. Sync takes files from the current checkout, including uncommitted changes; uncommitted changes are not the pushed proof input. Do not expose claim authentication material in a terminal transcript or share it with the test repository.

After discovery has produced stable extest_… IDs, run the selected tests on the claim:

Repeat --external-test <extest_test-id> for each additional test:

bash
cofactor test-suite run --suite "Example browser tests" --sandbox <sandbox-id> \
  --external-test <extest_test-id> --org Acme

The claim must belong to the same Application as the suite. It supplies the Application version and environment for the run, overriding the suite's configured default environment. The run starts fresh isolated copies of that pinned head and environment; it does not run in the mutable claim overlay. The run output gives the external run ID, selected test IDs, Application SHA, test-source revision and run links. Destroy your claim when finished:

bash
cofactor sandbox destroy <sandbox-id> --org Acme

You may instead pin a GitHub v2 suite to a pushed commit with --at; exact test IDs are optional with that target. A sandbox claim and --at cannot be combined. --sandbox requires at least one --external-test, and it takes the environment from the claim, so do not add --environment. Exact selection cannot be mixed with --area, --external-spec or --external-grep.

Application and test revisions

The run records the Application commit and test-source revision separately. When the test repository is one of the repositories pinned in the Application version, the run uses that repository's pinned commit. It can differ from the primary Application SHA. An explicit proof rerun at a new Application version uses the new commit pinned for that repository. When the suite uses a test repository outside the Application's pinned repositories, Cofactor resolves the configured branch or tag once and records that independent revision. A proof rerun keeps the cited independent test revision. To prove changed tests from that repository, start and attach a new run using the desired pushed test revision. Image or uploaded sources keep their immutable image or bundle digest.

For a no-match result or a preparation error, inspect the run's result and diagnostic details with cofactor external-run get <run-id> and the focused commands in cofactor external-run guide. That guide covers no matches, preparation, skips, failures and run lifecycle. Discovery and execution need the configured source repository to remain accessible to the Application's existing repository connection.