Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hyperactive

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hyperactive - npm Package Compare versions

Comparing version 2.2.0 to 2.2.1

2

package.json
{
"name": "hyperactive",
"version": "2.2.0",
"version": "2.2.1",
"description": "Creates mocha tests for all hypermedia of your API",

@@ -5,0 +5,0 @@ "author": "Tabcorp Digital Technology Team",

@@ -14,4 +14,3 @@ # hyperactive

`hyperactive` crawls your API responses, and creates [mocha](https://github.com/visionmedia/mocha) tests for each unique link it finds.
Simply pass in some basic config and it will do the rest.
`hyperactive` crawls your API responses, and creates [mocha](https://github.com/visionmedia/mocha) tests for each unique link it finds. Simply pass in some basic config and it will do the rest.

@@ -35,2 +34,13 @@ ```js

Hyperactive will then recursively crawl your API, and make sure it can make a `GET` request to every URL.
Any `4xx` or `5xx` status code while crawling makes the corresponding test fail, and the usual Mocha summary gets printed at the end:
```
1) http://my-api.com/route/that/fails
Bad status 404
70 passing (2613ms)
1 failing
```
*Note:* `hyperactive` needs to run as part of a [mocha](https://github.com/visionmedia/mocha) test suite.

@@ -214,3 +224,18 @@ If you want to run it in a different context, just make sure `it` and `describe` are defined in the global scope.

### Can I configure failure thresholds?
By default, `hyperactive` fails any URL that responds with `4xx` or `5xx`. To handle intermittent issues, you can pass a custom `recover` function, which can make a test pass despite the errors. Note that this doesn't handle any errors returned from your custom `validate` function, this is just for recovering from HTTP errors.
For example, you can setup a threshold for `400` errors using:
```js
var failures = 0;
hyperactive.crawl({
recover: function(res) {
return (res.statusCode === 400 && ++failure < 10);
}
});
```
## How can I contribute?

@@ -217,0 +242,0 @@

// Generated by CoffeeScript 1.7.1
(function() {
var async, build, config, createIt, expandUrl, linkFilter, linkFinder, localItFunction, setIt, templates, validate, _;
var DEFAULT_CONFIG, async, build, config, createIt, expandUrl, linkFilter, linkFinder, localItFunction, setIt, templates, validate, _;

@@ -17,14 +17,28 @@ _ = require('lodash');

DEFAULT_CONFIG = function() {
return {
url: null,
options: {},
templateValues: {},
samplePercentage: 100,
getLinks: linkFinder.getLinks,
validate: function() {
return true;
},
recover: function() {
return false;
}
};
};
localItFunction = null;
config = null;
config = DEFAULT_CONFIG();
exports.getLinks = function(res) {
var getLinksFn;
getLinksFn = (config != null ? config.getLinks : void 0) != null ? config.getLinks : linkFinder.getLinks;
return linkFilter.filter(getLinksFn(res.body), config != null ? config.samplePercentage : void 0);
return linkFilter.filter(config.getLinks(res.body), config.samplePercentage);
};
exports.setConfig = function(userconfig) {
return config = userconfig;
return config = _.extend({}, DEFAULT_CONFIG(), userconfig);
};

@@ -56,3 +70,5 @@

if (!res.ok) {
return done("Bad status " + res.status + " for url " + res.url);
if (!config.recover(res)) {
return done("Bad status " + res.status + " for url " + res.url);
}
}

@@ -105,5 +121,2 @@ try {

validate = function(url, res) {
if ((config != null ? config.validate : void 0) == null) {
return true;
}
return config.validate(url, res.body);

@@ -126,6 +139,6 @@ };

linkFilter.reset();
config = null;
return localItFunction = null;
localItFunction = null;
return config = DEFAULT_CONFIG();
};
}).call(this);

@@ -30,8 +30,9 @@ // Generated by CoffeeScript 1.7.1

unprocessedLinks = exports.unprocessedLinks(links);
if (samplePercentage == null) {
if (samplePercentage === 100) {
return unprocessedLinks;
} else {
return _.sample(unprocessedLinks, exports.linksToSample(unprocessedLinks.length, samplePercentage));
}
return _.sample(unprocessedLinks, exports.linksToSample(unprocessedLinks.length, samplePercentage));
};
}).call(this);
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc