Getting Started - Script

Follow this guide for a basic example with a Node.js Script scenario. Node.js scripts are written in Javascript and execute in a sandboxed Node.js environment. You can start from scratch or convert a Recording into a script as a starting point.

Start by signing up for an account and logging in if you have not already done so.

Create New Test Case

After logging in you should see a Create Test button on the dashboard. Click on it to get started. There are four steps: Name, Scenario, Configuration, and Results. We will examine each step one by one below.

For the sake of this test we will use our example REST API endpoint found at http://sample.testable.io. Give the test a name like ‘Demo’ and press enter or next.

Scenario

The scenario is the set of steps that will be executed during your test. In this guide we will choose the Node.js Script option.

Quite a few templates are provided to get you started quickly. We’ll use MochaJS syntax and a script that simply requests a stock quote from our dummy REST API:

const axios = require('axios');
const assert = require('assert');

describe('My Test Suite', function() {
  it('Get IBM quote', async function() {
    const quote = await axios({ url: `http://sample.testable.io/stocks/IBM`, responseType: 'json' });
    assert(quote.data.symbol === 'IBM', `Symbol of the quote should be IBM`);
  });
});

Try your script out by clicking the Smoke Test button in the upper right. This will execute your script one time on one of our Testable test runners and show you the results it captured.

Now let’s turn this into a real load test. Click on the Configuration tab or press the Next button at the bottom.

Configuration

Now that we have the scenario for our test case (i.e. GET http://sample.testable.io/stocks/IBM) we need to define a few parameters before we can execute our test:

  1. Total Virtual Users: Number of users that will execute in parallel. Each user will execute your Node.js script.
  2. Test Length: Select Iterations to have each client execute the scenario a set number of times regardless of how long it takes. Choose Duration if you want each client to continue executing the scenario for a set amount of time (in minutes).
  3. Location(s): Choose the location in which to run your test and the test runner source that indicates which test runners to use in that location to run the load test (e.g. on the public shared grid).

And that’s it! Press Start Test and watch the results start to flow in. See the new configuration guide for full details of all configuration options.

For the sake of this example, let’s use the following parameters:

Test configuration

View Results

Once the test starts executing, Testable will distribute the work out to the selected test runners (e.g. Public Shared Grid in AWS N. Virginia).

Test results

In each region, the Testable test runners execute the scripted scenario with 5 virtuals 2 minutes. Each virtual user will keep executing our Mocha script with a 1 second pause between iterations until at least 2 minutes has passed.

We offer integration (Org Management -> Integration) with third party tools like New Relic. If you enable integration you can do more in depth analytics on your results there as well.

That’s it! Go ahead and try these same steps with your favorite website or API and feel free to contact us with any questions.