Knowledge Base

  1. Home
  2. Knowledge Base
  3. Technical Support
  4. Script Commands
  5. rtcSetTestExpectation()

Indicate expected outcome for the specific probe execution. This is used to decide if a test has successfully passed or failed.

The condition is evaluated at the end of the test, based on collected information and metrics. The command can be placed anywhere in the script and can appear multiple times with different constraint values.


Name Type Description
criteria string The criteria to test. See below for the available options
message string Message to invoke if criteria isn’t met
level string Level of expectation:

  • “error” – error occured – fail the test
  • “warning” – consider this as a warning
  • Default value: error


A criteria is comprised of the metric to test, an operator and a value.

For example: “ > 0” will evaluate that the number of incoming video channels is greater than 0.


The available operators for the criteria are:

  • ==
  • >
  • <
  • >=
  • <=
  • !=

Criteria metrics

The criteria is defined as a chained definition of the object we wish to evaluate.

The chain hierarchy is:

Media type (audio / video) . Direction (in / out) . channels . Evaluated criteria

Where the channels level is optional, i.e. both formats will work:

  1. – Evaluates the total bitrate of all incoming video channels
  2. – Evaluates the bitrate of each outgoing audio channel separately
Evaluated criteria Media type Direction Global (all channels) Per channel Description and example
Connection duration Evaluate the duration of the whole peer connection session in seconds
“connectionDuration > 60”
Number of channels audio | video in | out Yes No Evaluate the number of channels
“video.out >= 1”
Channel is empty audio | video in | out Yes Yes Evaluate if the total number of sent/received packets is zero
“ == 0”
Bitrate audio | video in | out  Yes  Yes “audio.out.bitrate >= 3” – evaluate the TOTAL aggregated bitrate of all outgoing audio channels
“ > 3” – evaluate the value of EACH outgoing audio channel’ bitrate (evaluating all channels, per channel)

Also supports min/max postfix: “video.out.bitrate.max < 500” or “ > 30”

Packet loss audio | video in | out Yes Yes Evaluate channels’ packet loss (in %)
“packetloss < 2”
Packets lost audio | video in | out Yes Yes Evaluate the number of packets lost on the channel
“packetslost < 20”
Data audio | video in | out Yes Yes Evaluate total amount of sent/received bytes in the whole session
Packets audio | video in | out Yes Yes Evaluate the total number of packets sent/received
Roundtrip audio | video in | out Yes Yes Evaluate the average round trip time

Also supports min/max postfix: “video.out.roundtrip.max < 200” or “ > 200”

Jitter audio | video in | out Yes Yes Evaluate the average jitter value on the network (based on jitterReceived getstats metric)
“ < 200”

Also supports min/max postfix: “ < 500” or “ > 100”

Jitter Buffer audio | video in | out Yes Yes Evaluate the jitter buffer size (based on jitterBufferMs getstats metric)
“ < 200”
Codec audio | video in | out Yes Yes Evaluate the codec name
“ == ‘OPUS'”
“audio.out.codec == ‘opus,vp8′”
fps video in | out Yes Yes Evaluate frames per second

  • “ > 25” (calculate value from googFrameRateDecoded getstats metric)
  • “ > 25” (calculate value from googFrameRateSent getstats metric)
  • Also supports min/max postfix: “ < 32” or “ > 25”
Resolution video in | out Yes Yes Evaluate video resolution
“ == ‘640×480’ “
Time  – Evaluate the value of a timer, managed using the function .rtcGetTimer()
Metric  – Evaluate the value of a metric, managed using the function .rtcSetMetric()

Code examples:

Listed below are general examples of how you can use test expectations in your code:


Below is an example of how an error will show in the report:



The following example shows how expectations can be used based on scope. In this case, different expectations for different probes in the same test run:


Was this article helpful?

Related Articles

Leave a Reply 2 comments

David Pautler - February 1, 2019 Reply

My test result was “Agent 1: Failed test expectation [ == 1], Actual [0]”. I came to this page to find more explanation of this problem and what I can do about it.

FWIW, my guess is that signalling succeeded but that negotiation for media (encrypted) failed.

The test did succeed yesterday when there was no throttling.

    Tsahi Levent-Levi - February 1, 2019 Reply

    This does indicate that you were expecting a single incoming audio channel and got none.

    The issue might not be in the packet loss in this case. If you look at the webrtc-internals dump (download it), there’s nothing there. Just getusermedia and no peerconnections. It breaks before even trying.

Leave a Reply: