Network request - test subject¶
- Android - WebView apps
- Apple TV (tvOS) Simulator
- Browsers
- HbbTV / Freeview Play
- LG webOS
- NextGen TV / ATSC 3.0
- PlayStation 4/5
- Roku
- Samsung Tizen
- Sky
- VIDAA
- Vizio SmartCast
- Xbox (One, Series X/S)
- Xfinity / Xumo TV / XClass TV
- Other Smart TVs and STBs - HTML apps
Network request test subject represent a single network request made during the test execution.
Assertions involving the network request subject will only work when:
- using Suitestify
- using Lite solution on LG webOS, Samsung Tizen, Sky, VIDAA and Xfinity / Xumo TV / XClass TV
- testing on Xbox (One, Series X/S) devices
- testing tvOS apps on simulators
Xbox (One, Series X/S) limitation
Start and end time of requests is not available, therefore, requests are only shown once they are completed.
tvOS limitation
Network requests can only be used with simulators (not with physical devices) and do not cover the body of requests (only header, status, URL and method).
size limitation
Suitest does not allow to assert on a body of a network request/response bigger than 20 KB.
Basic Usage¶
To check if the app has loaded a particular URL:
In Test editor:
In the Suitest JavaScript API use the
networkRequest
subject:
await suitest.assert.networkRequest().equal('https://suite.st/docs/').wasMade();
Matching a set of URLs¶
Instead of looking for an exact URL, you can look for a substring.
In Test editor:
In JavaScript API:
await suitest.assert.networkRequest().contains('suite.st').wasMade();
This is especially useful if the URL you are looking for contains dynamic parameters.
Matching repetitive requests¶
Sometimes the app may load the same or similar URL multiple times. You can instruct Suitest to ignore the requests that have previously had a match.
In Test editor:
In JavaScript API:
await suitest.assert.networkRequest().contains('suite.st').willBeMade();
Matching headers¶
You can add HTTP headers to the assertion. Both request and response headers are supported.
In Test editor:
In JavaScript API:
await suitest.assert.networkRequest().equals('http://file.suite.st/sampleapp/index-hbbtv.html').requestMatch([
{
name: suitest.NETWORK_PROP.METHOD,
val: suitest.NETWORK_METHOD.GET,
}
]).responseMatch([
{
name: NETWORK_PROP.STATUS,
val: 200,
},
{
name: 'Content-Type',
val: 'application/vnd.hbbtv.xhtml+xml',
},
]).wasMade();
HTTP headers containing random or changing information are most of the time not suited for assertions.
Network log life cycle¶
Suitest starts a fresh network log at every test execution initiation. The log is empty at the beginning and fills up as the application progresses through the test. All assertions involving the network request subject are made against that log.
When running the test line-by-line every next execution is considered a separate test run and the network log is cleared. Therefore if you run only the line with a network request assertion it will most definitely fail. You should run the network assertion line together with other parts of the test that will ensure that the network log is properly filled.
Creating network assertions from Suitest console¶
All network requests made during interactive sessions are listed in Suitest console. You can easily add an assertion based on that network request to your test by pressing Create assertion link