
# Installing TestGlance for Cypress

## 1. Make tests emit JUnit XML

Install the multi-reporter and the JUnit reporter:

```bash
npm install --save-dev cypress-multi-reporters mocha-junit-reporter
# or: pnpm add -D cypress-multi-reporters mocha-junit-reporter
# or: yarn add -D cypress-multi-reporters mocha-junit-reporter
```

Update `cypress.config.ts` (or `cypress.config.js`):

```ts
// cypress.config.ts
import { defineConfig } from 'cypress';

export default defineConfig({
  reporter: 'cypress-multi-reporters',
  reporterOptions: {
    reporterEnabled: 'spec, mocha-junit-reporter',
    mochaJunitReporterReporterOptions: {
      mochaFile: 'test-results/cypress-[hash].xml',
      toConsole: false,
    },
  },
});
```

The `[hash]` placeholder gives each spec a unique filename so multi-spec
runs do not overwrite each other. TestGlance will pick up every file under
`test-results/`.

## 2. Add the TestGlance step to CI

If the project already has a CI workflow that runs the tests, add this step
to the test job (after the test step), and merge the `permissions:` block at
the workflow's top level:

```yaml
permissions:
  contents: read
  pull-requests: write

# ...inside the test job, after the test step:
- uses: testglance/action@v1
  if: always()
  with:
    github-token: ${{ github.token }}
```

If no CI workflow runs the tests yet, create
`.github/workflows/testglance.yml` that runs the project's tests and then
runs the TestGlance step.

`if: always()` matters — TestGlance should still run when tests fail.
TestGlance auto-discovers anything matching `**/test-results/*.xml`, so no
`report-path` is needed when reports land under `test-results/`.

## 3. Confirm with the user before committing

Summarize the diff and ask the user to confirm before staging or
committing. Do not push.
