Skip to content
QASignoff

Documentation

Tests & scripts

Write pre-request scripts and qa.test assertions in the Signoff dialect.

  • Platform Availability: Windows App · VS Code Extension
  • Overview: Check responses with or without code, and run scripts before or after a request. Scripts from Postman, Bruno, Thunder Client, Insomnia and Hoppscotch are supported too.

Add checks without code

Open Tests and click Add assert to check the status, response time, headers, body or a JSONPath value. You can also click Assert in a response to choose from suggested checks.

Tests tab with no-code checks and a test script

Write a script

  • Pre-request Script runs before the request.
  • Tests runs after the response.
  • For a script shared by a whole collection, open the collection and choose Scripts or Tests. For a folder, right-click it and choose Open Scripts.

Pre-request Script editor

Use qa.* for new scripts:

// Pre-request Script
qa.variables.set("ts", String(Date.now()));
// Tests
qa.test("status is 200", () => {
  qa.expect(qa.response.code).to.equal(200);
});

qa.test("the response includes a URL", () => {
  const body = qa.response.json();
  qa.expect(body.url).to.be.a("string");
});

// Save a value for a later request
qa.variables.set("gotUrl", qa.response.json().url);

Type {{ in a script to choose a variable. Script errors point to the line in your own code.

Use scripts from other tools

ToolSupported scripts
Postmanpm.*, plus older scripts that use responseBody, tests[...] and postman.*
Brunobru.*, req and res
Thunder Clienttc.*
Insomniainsomnia.*
Hoppscotchpw.* and hopp.*
pm.test("status is 200", function () {
  pm.response.to.have.status(200);
});

pm.expect, insomnia.expect, and expect in Bruno and Thunder Client use Chai, so its checks work the same way.

Load libraries

require() works with these bundled libraries:

  • Checks and validation: Chai, tv4, Ajv
  • Data and dates: lodash, Moment, uuid, csv-parse, papaparse
  • XML and security: xml2js, fast-xml-parser, crypto-js, jsonwebtoken
  • Requests and built-ins: axios, node-fetch, crypto, url, path, querystring, util, events, assert and buffer

Other npm packages aren't available. If a module can't run in the script sandbox, such as fs, the error suggests an alternative.

What isn't supported

These calls stop with a clear error: pm.execution.runRequest, bru.runRequest, tc.runRequest, tc.readFile and tc.exec. req.onFail and bru.getProcessEnv only log a warning.

Wait and run more requests

  • qa.sleep, tc.delay, bru.sleep, setTimeout and setInterval really do wait. Each script can spend up to 60 seconds on timers and extra requests.
  • qa.sendRequest sends another request from a script. Make sure it can't keep calling itself.
  • Scripts can also use WebSocket, SSE and gRPC through qa.ws, qa.sse and qa.grpc.
  • What you can do with qa.db, qa.load, qa.files and qa.ui depends on where the script runs.

How long variables last

In a collection run, a value set in one request is available to later requests. This works with qa.variables.set, pm.variables.set and bru.setVar. Numbers and objects keep their type.

Collection fromWhat happens to these values
SignOff Studio or PostmanKept for the run, but cleared between manual sends
BrunoKept for the run and between manual sends

In a run with a data file, a value set with pm.variables.set in a SignOff Studio or Postman collection takes priority over a column with the same name. In Bruno collections, the data file takes priority. Variables declared on a request last only for that request.

Values of variables marked as secret appear as [SECRET] in script logs.

Next

Need something else? See the FAQ. Questions: [email protected]. Bugs: [email protected].