# Merge your test reports together into a single artifact
testpilot_merge:
  stage: merge
  needs:
    - "testpilot-install-linux-amd64"
    - job: "testpilot-test"
      artifacts: true
      optional: true
  script: ./bin/testpilot report merge --outdir=testpilot-out testpilot-out-*
  artifacts:
    paths:
      - testpilot-out/
    when: always
    expire_in: 1 week
```

## Understanding the Component[​](#understanding-the-component "Direct link to Understanding the Component")

### Behind the Scenes[​](#behind-the-scenes "Direct link to Behind the Scenes")

When you include the Testpilot component, it creates a job that:

1. **Downloads the installer** from `https://get.jetify.com/testpilot`
2. **Installs Testpilot** and its dependencies (Playwright, Node.js)
3. **Creates a launcher script** at `./bin/testpilot` that handles environment setup
4. **Caches everything** so future pipeline runs are faster
5. **Shares the installation** with your test jobs via GitLab artifacts

### Component Configuration Options[​](#component-configuration-options "Direct link to Component Configuration Options")

The component accepts these parameters:

| Parameter        | Required | Default       | Description                         | Example                |
| ---------------- | -------- | ------------- | ----------------------------------- | ---------------------- |
| `stage`          | ✅ Yes    | -             | Which stage to install Testpilot in | `install`              |
| `platform`       | No       | `linux-amd64` | Target platform                     | `macos`, `linux-arm64` |
| `runner-extends` | No       | -             | Custom runner configuration         | `.macos_saas_runners`  |
| `xdg_cache_home` | No       | `.cache`      | Cache directory location            | `.custom_cache`        |

## Caching and Performance[​](#caching-and-performance "Direct link to Caching and Performance")

### Caching Strategy[​](#caching-strategy "Direct link to Caching Strategy")

The component automatically caches:

* The Testpilot binary and dependencies
* Your `./bin/testpilot` launcher script

This means the second time your pipeline runs, Testpilot installation will be much faster!

### Custom Cache Directory[​](#custom-cache-directory "Direct link to Custom Cache Directory")

If you need to change where files are cached:

```yaml theme={null}
include:
  - component: gitlab.com/jetify-com/gitlab-components/testpilot-install@main
    inputs:
      stage: install
      xdg_cache_home: .my_custom_cache

run-tests:
  stage: test
  needs: ["testpilot-install-linux-amd64"]
  script:
    - ./bin/testpilot test tests/
```

## Best Practices Summary[​](#best-practices-summary "Direct link to Best Practices Summary")

✅ **Do:**

* Always use `needs:` to ensure proper job dependencies
* Leverage the built-in caching for faster pipelines
* Use descriptive job names that reflect what you're testing
* Test on multiple platforms if your application supports them
* Structure your tests in logical directories

❌ **Don't:**

* Forget to specify the correct job name in `needs:`
* Modify the cache directory unless necessary
* Run tests without waiting for the installation job
* Use the same job name for multiple platforms