Http Client include js file

I have some tests written in http client.


For example 


GET {{ host }}/api/1.0/foo/bar

> foo/bar.js


var data = ...
var diffChecker = ...

client.test("Header", function () {
client.assert(response.status === 200, "Response status code should be 200");
client.assert(response.contentType.mimeType === "application/json", "Response content type should be application/json");

client.test("Whole response", function () {
var change = JSON.stringify(response.body) !== JSON.stringify(data);
if (change) {
var diff =, data);
for (var key in diff) {
var value = diff[key];
if (value.hasOwnProperty('type') && value.type !== 'unchanged') {
client.log(value.path + ": " + "[" + + "] should be [" + value.values.old + "]");
client.assert(!change, "different response");

The problem is that i have a lot of different endpoints stored in foo/*.js files but my code is exactly same except of data variable. 


Is there any way how to include some shared code ? or to inject data variable into > foo/bar.js

I have red documentation and tried Issue tracker as well but no luck so far.

Is anyone having same issue ? Did i get concept wrong ?

Comment actions Permalink

You can use variables in requests, see

If that doesn't work for you - please specify what part of your requests you would like to replace with a variable


Comment actions Permalink

Dmitry Tronin My problem is not a request but response validation. I am trying to validate response and for such purpose i am using object diffChecker and variable data


I have about 30 separated .js files which have almost the same content except for data variable.


I am looking fo a way how to cleanup these files in such a way that i have only one definition of diffChecker object in project 


Please sign in to leave a comment.