Assert performance metrics using phantomas
npm install juve
> Assert performance metrics using phantomas
A Node.js module that uses Phantomas to run performance tests against a given URL. It features the ability perform multiple trials against the same URL and make assertions against the combined average metrics.
juve module.``js`
var juve = require('juve');
This returns a function which accepts a configuration object and a callback with the following structure.
`js`
juve({
}, function (
...
});
#### options.trials
Type: Number3
Default value:
The number of times each URL will be sampled.
#### options.olympic
Type: Booleanfalse
Default value:
Indicates whether or not to use olympic-style scoring. This will drop the largest and smallest values for each metric before averaging the trials. Only available when the number of trials is greater than three (3).
#### options.url
Type: String/
Default value:
The URL to sample. This is combined with the baseUrl option to determine the full URL that will be sampled.
#### Assertions
The other keys of the options object can be taken directly from the phantomas documentation. The values indicate a maximum acceptable value. If multiple trials are used, the results will be averaged and compared to the asserted value.
function is a callback that gets called once all the trials have completed and the combined results are gathered.The argument is an object with three array properties:
-
pass: passing assertions
- fail: failed assertions
- trials: all asserted metric for each trial.The items in the
pass and fail lists look like:`javascript
{
name: "some metric",
expected: ,
actual:
}
`The items in the
trials list is the raw results from the underlying adapter (i.e. Phantomas).$3
As an alternative to passing a callback, the juve function returns a promise that will pass the results object when resolved.`javascript
juve('http://some.site.com', {
requests: 1
}).then(function (results) {
// do some things with the results.
});
`$3
#### Default Options
In this example, the default options are used to sample a single page from a target site. This asserts that the page does not make any extra requests.
`js
var juve = require('juve');juve('http://some.site.com', {
requests: 1
}, function (results) {
// do some things with the results.
});
`#### Custom Options
In this example, some task options are overridden within the target. This can tighen or relax some options on a per-page basis.
`js
var juve = require('juve');juve('http://some.site.com', {
requests: 1,
timeToFirstByte: 200
}, function (results) {
// do stuff with the results and stuff.
});
`Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style.Release History
$3
- The juve function accepts the url as the first parameter.
- The juve function returns a promise in addition to accepting a callback.
- The juve` function assumes all properties of the second parameter are assertions. The "options" property is reserved for specifying configuration options._(working towards v0.2.0)_