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

loadmill

Package Overview
Dependencies
Maintainers
1
Versions
100
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

loadmill - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

2

package.json
{
"name": "loadmill",
"version": "0.0.2",
"version": "0.0.3",
"description": "A node.js module for running load tests and functional tests on loadmill.com",

@@ -5,0 +5,0 @@ "keywords": [

@@ -17,5 +17,58 @@ # Loadmill

## Usage
The following code runs a very simple load test that gets a single page from `www.myapp.com` every second for one minute:
```js
const loadmill = require('loadmill')({token: process.env.LOADMILL_API_TOKEN});
// You may also give a path to a valid JSON file instead:
loadmill.run({requests: [{url: "www.myapp.com"}]}, (err, id) => {
if (!err) {
console.log("Load test started: " + id);
}
});
```
### Test Configuration
The JSON test configuration may be exported from the loadmill test editor or from an old test run.
Read more about the configuration format [here](https://docs.loadmill.com/test-configurations.html).
### Using Promises
Every function that accepts a callback will return a promise instead if no callback is provided (and vice versa):
```js
loadmill.run("./load-tests/simple.json")
.then(id => console.log("Load test started: ", id))
.catch(err => console.error("Something bad: ", err));
```
### Waiting for Tests
Since load tests usually run for at least a few minutes, the loadmill client does not wait for them to finish by default.
You can explicitly wait for a test to finish using the `wait` function:
```js
loadmill.run("./load-tests/long_test.json")
.then(loadmill.wait)
// -> {id: string, passed: boolean, url: string}
.then(result => console.log(result));
```
### Functional Tests
You may also use a test configuration to run a functional test (i.e. a single iteration of requests) - this is usually useful for testing your API for regressions after every new deployment.
Functional tests are expected to be shorter and thus are awaited on by default:
```js
loadmill.runFunctional("./load-tests/api_test.json")
// -> {id: string, passed: boolean, url: string}
.then(result => console.log(result));
```
### Parameters
You will usually want some part of your test to be _dynamic_, e.g. the host name of the tested server.
With Loadmill, this is made easy by using [parameters](https://docs.loadmill.com/parameters.html).
You may set/override parameter defaults for a test by passing a hash mapping parameter names to values:
```js
// Parameters may come before or instead of a callback:
loadmill.run("./load-tests/parametrized_test.json", {host: "test.myapp.com", port: 4443}, (err, id) => {/*...*/});
// You may also use predefined parameter values as well:
loadmill.runFunctional("./load-tests/parametrized_test.json", {host: "test.${parentDomain}"});
```
## CLI
## Learn More
Coming Soon...
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