> ## 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.

Deprecated 0.68.0

`testConnectionQuality(options)`

✓ Prebuilt✓ Custom

> [!WARNING]
>
> This method is deprecated. Use [`testCallQuality()`](https://docs.daily.co/reference/daily-js/instance-methods/test-call-quality) instead.

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()`](https://docs.daily.co/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.

## Parameters

**videoTrack** `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()`.

**duration** `number`

How long to run the test in seconds. Default: `15`. Maximum: `30`.

## Return value

Returns `Promise<DailyConnectionQualityTestStats>`.

**result** `'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()`](https://docs.daily.co/reference/daily-js/instance-methods/stop-test-connection-quality))

**data** `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)

**secondsElapsed** `number`

How long the test ran in seconds.

### 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

> [card] Methods
>
> * [testPeerToPeerCallQuality()](https://docs.daily.co/reference/daily-js/instance-methods/test-peer-to-peer-call-quality.md)
> * [stopTestConnectionQuality()](https://docs.daily.co/reference/daily-js/instance-methods/stop-test-connection-quality.md)
> * [testCallQuality()](https://docs.daily.co/reference/daily-js/instance-methods/test-call-quality.md)
> * [testNetworkConnectivity()](https://docs.daily.co/reference/daily-js/instance-methods/test-network-connectivity.md)
> * [getNetworkStats()](https://docs.daily.co/reference/daily-js/instance-methods/get-network-stats.md)

> [card] Events
>
> * [test-completed](https://docs.daily.co/reference/daily-js/events/network-events.md#test-completed)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.