Docs/Bring your own suite
#

Bring your own suite

Run the Playwright tests you already have on Cofactor, with each test on its own fresh copy of your app.

Run my existing Playwright suite on Cofactor

Cofactor runs your Playwright tests on sandboxes. Each test runs on its own fresh copy of your app, so one test can't change another's data and the whole suite runs in parallel. Results, artifacts and failure diagnoses come back to Cofactor. Your tests stay in your repository.

You need an application with a sandbox (Environments) and a Playwright suite in a GitHub repository. Selenium and Cypress suites are covered in Advanced.

Run your suite

  1. Link the repository to your application. Give the Cofactor GitHub App access to the repository that holds the tests. If it isn't installed yet, run cofactor github connect and approve it in your browser. Then link the repository.

    bash
    cofactor application list
    cofactor application repo link --application <application id> --repo acme/browser-tests
    
  2. Declare the suite. Add cofactor.tests.yaml at the repository root. It names the install command, your Playwright config and the values Cofactor fills in for each copy.

    yaml
    version: 1
    install: npm ci
    run:
      playwright:
        config: playwright.config.ts
    env:
      BASE_URL: ${app.url}
      QA_EMAIL: ${personas.qa.email}
      QA_PASSWORD: ${personas.qa.password}
      ACCOUNT_ID: ${seeds.account.accountId}
    

    Your tests read these from process.env, for example process.env.BASE_URL. Each reference must be the whole value of its entry. Persona and seed names come from your sandbox definition. Run cofactor sandbox envs --application <application id> to list them. A seed reference is ${seeds.<seed id>.<output name>}, where the output comes from that seed's action. Replace the sample names above with yours. See Seed data and logins.

  3. Check it locally. The first command checks the file's format. It does not check that the personas and seeds exist. The second installs your dependencies and confirms Playwright can list your tests without reaching an app. Set a placeholder value for any variable your config reads.

    bash
    cofactor test-suite validate .
    npm ci
    BASE_URL=https://example.com npx playwright test --config playwright.config.ts --list
    

    Then commit cofactor.tests.yaml and push it, or merge it, to the branch you name in --ref below. Ask before you push.

  4. Create the suite.

    bash
    cofactor test-suite create --name "Acme browser tests" --kind external \
      --provider playwright --source github --repo acme/browser-tests \
      --application "Acme App" --environment default
    cofactor test-suite update "Acme browser tests" --ref main --capture-policy retry --max-retries 1
    
  5. Run it. The first run finds your tests, then runs them in parallel, up to your plan's sandbox limit. New tests show as Unverified until they have a result. The command streams until the run finishes and prints the run id, which starts with extrun_. It exits 0 when no test fails. It exits 1 when a test fails, the run is canceled or it returns no results.

    bash
    cofactor test-suite run --suite "Acme browser tests"
    
  6. Read the results. Each failure has its artifacts, such as the trace, and a diagnosis written by an agent.

    bash
    cofactor external-run get <run id>
    cofactor external-run failures <run id>
    cofactor external-run triage <run id>
    cofactor external-run diagnosis <run id> --item <item id>
    cofactor external-run trace <run id> --item <item id>
    

    The item id comes from get or failures.

To rerun the tests that failed, were flaky or were skipped, run cofactor external-run rerun <run id> --failed on a finished run.

Check it worked

bash
cofactor external-run get <run id>

The run lists every test with a result and a stable test id that starts with extest_. A run with no tests is a setup problem, so run cofactor external-run debug overview <run id> to see why. In the app, open External E2E tests to see the same catalog.

Go deeper

  • Suites and schedules puts the suite in CI and on a schedule.
  • Plans and limits shows how many sandboxes run at once.
  • Run cofactor test-suite guide and cofactor external-run guide for the full procedures.
Advanced

Other sources, large repositories, proofs and other test frameworks.

Other sources. --source image runs tests that ship in your application's image, using the cofactor.tests.yaml in its working directory. --source upload runs a bundle you push with cofactor test-suite push "<suite>" <directory>. Both take --provider playwright and your --application. An image source also needs --environment.

Large repositories. Add source.paths to cofactor.tests.yaml to fetch only the files install and your tests need, such as package.json, the lockfile and the test directory. Without it, the whole repository archive can be up to 128 MiB compressed. If a run reports EXTERNAL_TEST_SOURCE_TOO_LARGE, add the paths and run again.

Identity. A test is known by its source, file, project and title path. Renaming a test creates a new test, and the old one keeps its history.

Proofs. A complete passing or flaky result can prove a pull request criterion. Run cofactor test-suite guide proofs.

Selenium and Cypress. The setup above is for Playwright. Selenium and Cypress suites use a runner that Cofactor sets up with you, so contact us before you start.