> ## Documentation Index
> Fetch the complete documentation index at: https://docs.daily.co/llms.txt
> Use this file to discover all available pages before exploring further.

# testConnectionQuality()

> Deprecated. Tests WebRTC connection quality using a video track before joining a call.

<Badge color="yellow">Deprecated 0.68.0</Badge>

`testConnectionQuality(options)`

<Badge color="green">{"✓"} Prebuilt</Badge> <Badge color="green">{"✓"} Custom</Badge>

<Warning>
  This method is deprecated. Use [`testCallQuality()`](/reference/daily-js/instance-methods/test-call-quality) instead.
</Warning>

Assesses WebRTC connection quality by connecting to Daily's TURN servers and measuring round-trip time and packet loss over the test duration. Useful for precall checks before a room is joined.

The test runs for 15 seconds by default (up to 30 seconds). The longer it runs, the more accurate the results. For in-depth network stats *during* a call, use [`getNetworkStats()`](/reference/daily-js/instance-methods/get-network-stats).

<Note>
  A result does not determine whether a user is allowed to join a call — it's up to you to decide what to do with `'bad'` or `'warning'` results.
</Note>

## Parameters

<ParamField body="videoTrack" type="MediaStreamTrack" required>
  A video track used to establish the test connection. You can obtain one from `call.participants().local.tracks.video.persistentTrack` after calling `startCamera()`.
</ParamField>

<ParamField body="duration" type="number">
  How long to run the test in seconds. Default: `15`. Maximum: `30`.
</ParamField>

## Return value

Returns `Promise<DailyConnectionQualityTestStats>`.

<ResponseField name="result" type="'good' | 'warning' | 'bad' | 'failed' | 'aborted'">
  Overall connection quality verdict. The result is determined when any one condition is met:

  * `'good'` — `packetLoss` \< 5% and `maxRTT` \< 300ms
  * `'warning'` — `packetLoss` 5–10% or `maxRTT` 300–600ms
  * `'bad'` — `packetLoss` ≥ 10% or `maxRTT` ≥ 600ms
  * `'failed'` — connection to Daily's TURN servers could not be made
  * `'aborted'` — test stopped before data gathering started (via [`stopTestConnectionQuality()`](/reference/daily-js/instance-methods/stop-test-connection-quality))
</ResponseField>

<ResponseField name="data" type="DailyConnectionQualityTestData">
  The raw metrics used to determine the result:

  * `maxRTT` (seconds) — the highest [`currentRoundTripTime`](https://developer.mozilla.org/en-US/docs/Web/API/RTCIceCandidatePairStats/currentRoundTripTime) sampled during the test
  * `packetLoss` (percentage) — calculated from [`packetsLost`](https://www.w3.org/TR/webrtc-stats/#dom-rtcreceivedrtpstreamstats-packetslost) and [`packetsReceived`](https://www.w3.org/TR/webrtc-stats/#dom-rtcreceivedrtpstreamstats-packetsreceived)
</ResponseField>

<ResponseField name="secondsElapsed" type="number">
  How long the test ran in seconds.
</ResponseField>

### Example response

```json theme={null}
{
  "result": "good",
  "data": {
    "maxRTT": 0.054,
    "packetLoss": 0.0802
  },
  "secondsElapsed": 15
}
```

## Example

```javascript theme={null}
await call.startCamera();
const videoTrack = call.participants().local.tracks.video.persistentTrack;

const results = await call.testConnectionQuality({ videoTrack, duration: 10 });

switch (results.result) {
  case 'aborted':
    console.log('Test aborted before data was gathered.');
    break;
  case 'failed':
    console.warn('Unable to connect to TURN servers.');
    break;
  case 'bad':
    console.warn('Poor connection. Try a different network.');
    break;
  case 'warning':
    console.warn('Connection may be unstable.');
    break;
  case 'good':
  default:
    console.log('Connection quality is good.');
}
```

## See also

<CardGroup>
  <Card title="Methods" icon="code" iconType="solid">
    * [testPeerToPeerCallQuality()](/reference/daily-js/instance-methods/test-peer-to-peer-call-quality)
    * [stopTestConnectionQuality()](/reference/daily-js/instance-methods/stop-test-connection-quality)
    * [testCallQuality()](/reference/daily-js/instance-methods/test-call-quality)
    * [testNetworkConnectivity()](/reference/daily-js/instance-methods/test-network-connectivity)
    * [getNetworkStats()](/reference/daily-js/instance-methods/get-network-stats)
  </Card>

  <Card title="Events" icon="bolt" iconType="solid">
    * [test-completed](/reference/daily-js/events/network-events#test-completed)
  </Card>
</CardGroup>
