Steps to manage proxy.
These methods are mixed with glacejs Steps class and available via its instance $ in tests.
- Source:
Properties:
Name | Type | Description |
---|---|---|
webUrl |
string | Web application URL. |
globalProxy |
GlobalProxy | Global proxy instance. |
httpProxy |
HttpProxy | HTTP proxy instance. |
Methods
-
disableCache()
-
Step to disable cache.
Returns:
true
if step is passed.- Type
- boolean
Example
$.disableCache();
-
enableCache()
-
Step to enable cache.
Returns:
true
if step is passed.- Type
- boolean
Example
$.enableCache();
-
getProxyUrl( [opts])
-
Step to get proxy URL.
Parameters:
Name Type Argument Description opts
object <optional>
Step options.
Properties
Name Type Argument Default Description check
boolean <optional>
true Flag to check that proxy URL is defined.
Throws:
-
If proxy URL isn't defined.
- Type
- AssertionError
Returns:
Proxy URL.
- Type
- string
Example
var proxiedUrl = $.getProxiedUrl();
-
-
getResponsesData( [opts])
-
Step to get measured responses data.
Parameters:
Name Type Argument Description opts
object <optional>
Step options.
Properties
Name Type Argument Default Description check
boolean <optional>
true Flag to check that responses data are present.
Throws:
-
If responses data are absent.
- Type
- AssertionError
Returns:
List of captured response data.
- Type
- Array.<object>
Example
var responses = $.getResponsesData();
-
-
limitProxySpeed(speed [, opts])
-
Step to limit proxy speed.
Parameters:
Name Type Argument Description speed
number | object Proxy limited speed, kb/s.
Properties
Name Type Argument Description req
number <optional>
<nullable>
Requests speed, kb/s.
res
number <optional>
<nullable>
Responses speed, kb/s.
opts
object <optional>
Step options.
Properties
Name Type Argument Default Description check
boolean <optional>
true Flag to check that proxy speed is limited.
Throws:
-
If proxy speed is not limited.
- Type
- AssertionError
Returns:
true
if step was passed.- Type
- boolean
Example
$.limitProxySpeed(512); $.limitProxySpeed({ res: 512 });
-
-
measureResponses( [opts])
-
Step to start responses measurement.
Parameters:
Name Type Argument Description opts
object <optional>
Step options.
Properties
Name Type Argument Default Description check
boolean <optional>
true Flag to check that responses measurement is launched.
Throws:
-
If responses measurement is not launched.
- Type
- AssertionError
Returns:
true
if step is passed.- Type
- boolean
Example
$.measureResponses();
-
-
registerProxy( [opts])
-
Helper to register proxy classes.
Parameters:
Name Type Argument Description opts
object <optional>
Options.
Properties
Name Type Argument Description GlobalProxy
object <optional>
Global proxy class.
HttpProxy
object <optional>
HTTP proxy class.
Example
$.registerProxy({ GlobalProxy: MyGlobalProxy, HttpProxy: MyHttpProxy });
-
<async> startGlobalProxy( [opts])
-
Step to start global proxy. Step recall will be skipped if global proxy wasn't stopped before.
Parameters:
Name Type Argument Description opts
object <optional>
Step options.
Properties
Name Type Argument Default Description useCache
boolean <optional>
Flag to use proxy cache for responses. Default value will be requested from
config.useCache
if it is specified.timeout
number <optional>
Proxy timeout to break connection. Default value will be requested from
config.timeout.proxy
.reconnect
number <optional>
Number of proxy reconnects on failure.
port
number <optional>
Proxy port. Default value will be requested from
config.globalProxyPort
.check
boolean <optional>
true Flag to check that proxy was launched.
Throws:
-
If global proxy was not launched.
- Type
- AssertionError
Returns:
true
if step was passed,false
if was skipped.- Type
- Promise.<boolean>
Example
await $.startGlobalProxy(); await $.startGlobalProxy({ timeout: 30000 });
-
-
<async> startHttpProxy( [opts])
-
Step to start HTTP proxy. Step recall will be skipped if proxy wasn't stopped before.
Parameters:
Name Type Argument Description opts
object <optional>
Step options.
Properties
Name Type Argument Default Description webUrl
string <optional>
Web application url which will be proxied. Default value will be requested from
config.web.url
if it is specified.useCache
boolean <optional>
Flag to use proxy cache for responses. Default value will be requested from
config.useCache
if it is specified.timeout
number <optional>
Proxy timeout to break connection. Default value will be requested from
config.timeout.proxy
.reconnect
number <optional>
Number of proxy reconnects on failure.
port
number <optional>
Proxy port. Default value will be requested from
config.proxyPort
.check
boolean <optional>
true Flag to check that proxy was launched.
Throws:
-
If proxy was not launched.
- Type
- AssertionError
Returns:
-
Proxied URL.
- Type
- Promise.<string>
-
false
if step was skipped- Type
- Promise.<boolean>
Example
var proxiedUrl = await $.startHttpProxy(); var proxiedUrl = await $.startHttpProxy({ webUrl: "http://example.com", }); var proxiedUrl = await $.startHttpProxy({ webUrl: "http://example.com", port: 8080 });
-
-
<async> stopGlobalProxy( [opts])
-
Step to stop global proxy. Step call will be skipped if global proxy wasn't launched before.
Parameters:
Name Type Argument Description opts
object <optional>
Step options.
Properties
Name Type Argument Default Description check
boolean <optional>
true Flag to check that global proxy was stopped.
Throws:
-
If global proxy wasn't stopped.
- Type
- AssertionError
Returns:
true
if step was passed,false
if was skipped.- Type
- Promise.<boolean>
Example
await $.stopGlobalProxy();
-
-
<async> stopHttpProxy( [opts])
-
Step to stop HTTP proxy. Step call will be skipped if proxy wasn't launched before.
Parameters:
Name Type Argument Description opts
object <optional>
Step options.
Properties
Name Type Argument Default Description check
boolean <optional>
true Flag to check that proxy was stopped.
Throws:
-
If proxy wasn't stopped.
- Type
- AssertionError
Returns:
true
if step was passed,false
if was skipped.- Type
- Promise.<boolean>
Example
await $.stopHttpProxy();
-
-
unlimitProxySpeed( [opts])
-
Step to unlimit proxy speed.
Parameters:
Name Type Argument Description opts
object <optional>
Step options.
Properties
Name Type Argument Default Description check
boolean <optional>
true Flag to check that proxy speed is unlimited.
Throws:
-
If proxy speed is still limited.
- Type
- AssertionError
Returns:
true
if step is passed.- Type
- boolean
Example
$.unlimitProxySpeed();
-
-
unmeasureResponses( [opts])
-
Step to stop responses measurement.
Parameters:
Name Type Argument Description opts
object <optional>
Step options.
Properties
Name Type Argument Default Description check
boolean <optional>
true Flag to check that responses measurement is stopped.
Throws:
-
If responses measurement is still running.
- Type
- AssertionError
Returns:
true
if step is passed.- Type
- boolean
Example
$.unmeasureResponses();
-