# Testing Resources 🧪

## Overview

CardScan.ai maintains a [public testing repository](https://github.com/CardScan-ai/testing-resources) with sample insurance cards and test videos for validating your integration. These resources help ensure consistent testing across development, staging, and CI/CD environments.

{% hint style="info" %}
All test cards are synthetic samples for testing purposes only. They do not contain real patient information.
{% endhint %}

## Quick Start

1. **Clone the repository:**

   ```bash
   git clone https://github.com/CardScan-ai/testing-resources.git
   ```
2. **Use sample cards** from `insurance-card-images/` for testing
3. **Use test videos** from `insurance-test-videos/` for automated testing

## Browser Testing with Fake Webcam

### Chrome Launch Flags

Test with consistent video input instead of a live webcam:

```bash
# macOS
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome \
  --use-fake-device-for-media-stream \
  --use-file-for-fake-video-capture=./path/to/test-video.y4m

# Windows
chrome.exe \
  --use-fake-device-for-media-stream \
  --use-file-for-fake-video-capture=./path/to/test-video.y4m

# Linux
google-chrome \
  --use-fake-device-for-media-stream \
  --use-file-for-fake-video-capture=./path/to/test-video.y4m
```

### Cypress Integration

Configure Cypress to use test videos as webcam input:

**1. Update `cypress/plugins/index.js`:**

```javascript
module.exports = (on, config) => {
  on('before:browser:launch', (browser = {}, launchOptions) => {
    if (browser.family === 'chromium' && browser.name !== 'electron') {
      if (process.env.CYPRESS_WEBCAM_VIDEO_PATH) {
        console.log("Setting Video to be: ", process.env.CYPRESS_WEBCAM_VIDEO_PATH)
        launchOptions.args.push(
          `--use-file-for-fake-video-capture=${process.env.CYPRESS_WEBCAM_VIDEO_PATH}`
        )
      }
    }
    return launchOptions
  })
}
```

**2. Run tests with video input:**

```bash
CYPRESS_WEBCAM_VIDEO_PATH=./testing-resources/insurance-test-videos/1080p.y4m cypress run
```

**3. Example test:**

```javascript
describe('Card Scanning', () => {
  it('should scan test card successfully', () => {
    cy.visit('/scan')
    
    // Your CardScan implementation will receive video frames
    // from the test video instead of live webcam
    cy.get('[data-testid="scan-button"]').click()
    
    // Wait for scan completion
    cy.get('[data-testid="scan-complete"]', { timeout: 10000 })
      .should('be.visible')
  })
})
```

## Testing Best Practices

### 1. Test Multiple Scenarios

* Different card types and payers
* Various video resolutions
* Front and back card scanning
* Error conditions and edge cases

### 2. Continuous Integration

Example GitHub Actions workflow:

```yaml
name: E2E Tests
on: [push, pull_request]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      
      - name: Setup test resources
        run: |
          git clone https://github.com/CardScan-ai/testing-resources.git
          cd testing-resources/insurance-test-videos
          unzip videos.zip
      
      - name: Run tests
        env:
          CYPRESS_WEBCAM_VIDEO_PATH: ./testing-resources/insurance-test-videos/1080p.y4m
        run: |
          npm install
          npm run test:e2e
```

## Available Resources

The testing repository includes:

* **Sample card images** - High-quality insurance card images (front/back)
* **Test videos** - Pre-recorded scanning videos in multiple resolutions
* **Additional resources** - Check the repository for the latest test materials

{% hint style="warning" %}
The repository contents may change over time. Always check the [latest README](https://github.com/CardScan-ai/testing-resources/blob/main/README.md) for current resources.
{% endhint %}

## Related Documentation

* [React SDK Testing](/ui-components/react.md#testing)
* [React Native SDK Testing](/ui-components/react-native.md#testing)
* [API Testing](/api.md#testing-endpoints)
* [Webhooks Testing](https://github.com/CardScan-ai/cardscan-documentation/blob/master/developer-tools/webhooks.md#testing-webhooks)

## Support

Need help with testing?

* **Email**: <support@cardscan.ai>
* **Slack**: Available for Enterprise customers


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.cardscan.ai/developer-tools/testing-resources.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
