Skip to content

v2.10.0

Compare
Choose a tag to compare
@rangav rangav released this 31 Jul 11:59
· 196 commits to master since this release
27afc50

Assertions using Scripting

Today we are releasing a new feature: Test assertions using scripting. Developers can now use scripting to write assertions, based on the use case you can choose a scripting or GUI interface for assertions.

  • New function tc.test() added to tc object useful for assertions #465, #194, #347
  • You can write assertions and use them only in Post Request Filter in Tests tab
  • Update tc-types.d.ts to version 1.4.0
  • Update CLI to version v1.4.6

Assertions without any library

function testFilter() {
    let success = tc.response.status == 200;
    let json = tc.response.json;
    let containsThunder = json.message?.includes("thunder");

    tc.test("Response code is 200", success);
    tc.test("Response contains thunder word", containsThunder);

    // Assertions using function syntax
    tc.test("verifying multiple tests", function () {
            let success = tc.response.status == 200;
            let time = tc.response.time < 1000;
            return success && time;
    });
}

module.exports = [testFilter]

Assertions using Node Assert library

// using built-in node assert module
const assert = require("assert");

function testFilter() {
    console.log("test assertion filter");
    tc.test("Response code is 200", function () {
        assert.equal(tc.response.status, 200);
    })
}

module.exports = [testFilter]

Assertions using Chai library (updated in v2.11.4)

var chai = require("chai");
var expect = chai.expect;
var assert = chai.assert;

function testChaiFilter() {
    tc.test("Response code is 200", function () {
        assert.equal(tc.response.status, 200)
    })

    tc.test("Response code expect to be 200", function () {
        expect(tc.response.status).to.equal(200);
    })
}

module.exports = [testChaiFilter]

CLI

  • Single report for test run with multiple collections #1221
  • Display paths of generated reports #1233
  • --reqlist will accept request name or id #1234
  • Update CLI to version v1.4.6

Bug Fixes

  • response header value changed #1239
  • Cannot detect custom filter #1240