Network
See and change what a web app’s pages fetch, from the browser: requests that fail, answer with an error or a file, or take their time, a slow connection, a recording of the pages’ traffic to answer from, and the messages of their websockets. It builds on the web-core pack.
A request is named by its address, a path below the web app’s url (/api/prices) or a whole URL (https://maps.example.com/tiles/**): * stands for any part of a path, ** for any parts; the query does not count unless the address has one. What a step sets holds for every web app of the scenario, from the pages they open next: set it before the page opens.
The pages’ own requests only: for the services your app calls from its server, mock them instead (the mock pack). record: true in axx.yaml records what each web app’s pages fetch, for a scenario to answer from later.
Add it to a project with axx pack add web-network; it builds on web-core, which comes with it.
Settings
Section titled “Settings”In axx.yaml, under packs.web-network:
| Setting | Takes | Values | Default |
|---|---|---|---|
record |
Record what each scenario’s pages fetch, a HAR file for each web app in .axx/web/recordings, for scenarios to answer from. | true, false |
false |
web-network.fail
Section titled “web-network.fail”Given the page's requests to {string} failMake the pages’ requests to an address fail, as when a service is down or out of reach: a path below the web app’s url, or a whole URL, with * and **.
| Parameter | Takes | For example |
|---|---|---|
{string} |
text in double or single quotes, which the step leaves out | "Get a quote", 'Express' |
Example:
Given the page's requests to "https://maps.example.com/**" failSince 0.1.1.
web-network.status
Section titled “web-network.status”Given the page's requests to {string} answer with status {int}Answer the pages’ requests to an address with a status and nothing else, like 503.
| Parameter | Takes | For example |
|---|---|---|
{string} |
text in double or single quotes, which the step leaves out | "Get a quote", 'Express' |
{int} |
a whole number | 200, 3 |
Example:
Given the page's requests to "/api/prices" answer with status 503Since 0.1.1.
web-network.file
Section titled “web-network.file”Given the page's requests to {string} answer with the {filepath} fileAnswer the pages’ requests to an address with a file of the project, with the type of its extension.
| Parameter | Takes | For example |
|---|---|---|
{string} |
text in double or single quotes, which the step leaves out | "Get a quote", 'Express' |
{filepath} |
a file of the project: a path relative to the feature file’s directory, the resources directories or axx.yaml’s directory (looked for in that order), or an absolute path, quoted when it has a space |
seeds/parcels.yaml, kafka/scan-delivered.json |
Example:
Given the page's requests to "/api/prices" answer with the network/prices-berlin.json fileSince 0.1.1.
web-network.slow
Section titled “web-network.slow”Given the page's requests to {string} take {duration}Make the pages’ requests to an address take that long before they go out, as a busy service does.
| Parameter | Takes | For example |
|---|---|---|
{string} |
text in double or single quotes, which the step leaves out | "Get a quote", 'Express' |
{duration} |
a duration in seconds (s) or minutes (m) |
5s, 2m |
Example:
Given the page's requests to "/api/prices" take 3sSince 0.1.1.
web-network.connection.slow
Section titled “web-network.connection.slow”Given the browser's connection is slowMake the browser’s connection slow, as a phone’s in a bad spot: 400 ms of latency and 500 kbit/s each way. Chromium, Chrome and Edge only.
Example:
Given the browser's connection is slowSince 0.1.1.
web-network.recording
Section titled “web-network.recording”Given the page's requests are answered from the {filepath} recordingAnswer the pages’ requests from a recording of what they fetched, a HAR file (record: true makes them): the requests it has, it answers; the others go out, and so do websockets.
| Parameter | Takes | For example |
|---|---|---|
{filepath} |
a file of the project: a path relative to the feature file’s directory, the resources directories or axx.yaml’s directory (looked for in that order), or an absolute path, quoted when it has a space |
seeds/parcels.yaml, kafka/scan-delivered.json |
Example:
Given the page's requests are answered from the network/quote.har recordingSince 0.1.1.
web-network.ws.sent
Section titled “web-network.ws.sent”Then [[within {duration} ]]the page sent a websocket message containing {string}Check that a page of the scenario sent a websocket message with that text in it. The check waits: 10 seconds, or within {duration}.
| Parameter | Takes | For example |
|---|---|---|
{duration} |
a duration in seconds (s) or minutes (m) |
5s, 2m |
{string} |
text in double or single quotes, which the step leaves out | "Get a quote", 'Express' |
Variants, the parts in [[...]] said or left out:
the page sent a websocket message containing {string}within {duration} the page sent a websocket message containing {string}
Example:
Then the page sent a websocket message containing "subscribe:PX-4101"Since 0.1.1.
web-network.ws.received
Section titled “web-network.ws.received”Then [[within {duration} ]]the page received a websocket message containing {string}Check that a page of the scenario received a websocket message with that text in it. The check waits: 10 seconds, or within {duration}.
| Parameter | Takes | For example |
|---|---|---|
{duration} |
a duration in seconds (s) or minutes (m) |
5s, 2m |
{string} |
text in double or single quotes, which the step leaves out | "Get a quote", 'Express' |
Variants, the parts in [[...]] said or left out:
the page received a websocket message containing {string}within {duration} the page received a websocket message containing {string}
Example:
Then the page received a websocket message containing "IN_TRANSIT"Since 0.1.1.