> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/grafana/k6/llms.txt
> Use this file to discover all available pages before exploring further.

# Smoke Testing

> Learn how to validate your test script and system under minimal load using k6 smoke testing patterns.

Smoke testing validates that your test script works and your system performs adequately under minimal load. It's the first test you should run before any performance testing.

## Purpose

Smoke tests help you:

* Verify your test script runs without errors
* Ensure your system handles a small number of virtual users
* Validate test logic and API endpoints
* Catch obvious issues before larger tests

<Note>
  Always run a smoke test before executing load, stress, or soak tests to avoid wasting time on a broken script.
</Note>

## Configuration Pattern

Smoke tests use minimal VUs (1-5) for a short duration (1-5 minutes):

```javascript theme={null}
import http from 'k6/http';
import { check, sleep } from 'k6';

export const options = {
  vus: 1,
  duration: '1m',
  thresholds: {
    http_req_failed: ['rate<0.01'], // http errors should be less than 1%
    http_req_duration: ['p(95)<500'], // 95% of requests should be below 500ms
  },
};

export default function() {
  const res = http.get('https://quickpizza.grafana.com');
  check(res, {
    'status is 200': (r) => r.status === 200,
  });
  sleep(1);
}
```

## Using the Constant VUs Executor

The `constant-vus` executor maintains a fixed number of VUs:

```javascript theme={null}
export const options = {
  scenarios: {
    smoke: {
      executor: 'constant-vus',
      vus: 1,
      duration: '30s',
    },
  },
};
```

<CardGroup cols={2}>
  <Card title="VUs" icon="users">
    1-5 virtual users
  </Card>

  <Card title="Duration" icon="clock">
    1-5 minutes
  </Card>
</CardGroup>

## Typical Smoke Test Flow

<Steps>
  <Step title="Start with 1 VU">
    Begin with a single virtual user to validate basic functionality.
  </Step>

  <Step title="Run for short duration">
    Execute the test for 1-5 minutes to verify stability.
  </Step>

  <Step title="Check for errors">
    Monitor for script errors, failed requests, and threshold violations.
  </Step>

  <Step title="Validate responses">
    Ensure API responses contain expected data and status codes.
  </Step>
</Steps>

## Best Practices

<Tip>
  Use smoke tests as a sanity check in your CI/CD pipeline before running more intensive performance tests.
</Tip>

### What to Verify

* **Script execution**: No JavaScript errors or exceptions
* **API availability**: All endpoints are accessible
* **Response validation**: Checks pass successfully
* **Basic performance**: Response times are reasonable

### Example with Multiple Endpoints

```javascript theme={null}
import http from 'k6/http';
import { check } from 'k6';

export const options = {
  vus: 1,
  duration: '2m',
};

export default function() {
  // Test multiple endpoints
  const responses = http.batch([
    ['GET', 'https://quickpizza.grafana.com'],
    ['GET', 'https://quickpizza.grafana.com/api/pizza'],
  ]);

  check(responses[0], {
    'homepage status is 200': (r) => r.status === 200,
  });

  check(responses[1], {
    'api status is 200': (r) => r.status === 200,
    'api returns json': (r) => r.headers['Content-Type'].includes('application/json'),
  });
}
```

## When to Use

* **Before every test**: Always start with a smoke test
* **After script changes**: Validate modifications don't break functionality
* **In CI/CD**: Quick validation before deploying changes
* **New environments**: Verify system configuration

## Common Issues

<Warning>
  If your smoke test fails, fix the issues before running larger tests. Common problems include:

  * Incorrect URLs or endpoints
  * Authentication failures
  * Network connectivity issues
  * Missing test data
</Warning>
