Skip to content

Conversation

ihexxa
Copy link
Contributor

@ihexxa ihexxa commented Jul 17, 2025

Changes

  • fix: extend insomnia.response.to assertion with chai plugin utilities
  • Added and updated the UT accordingly

Try these in the after-response script:

insomnia.test('Check if status is 200', () => {
insomnia.response.to.be.error;
});

insomnia.test('withBody', () => {
	insomnia.response.to.be.withBody;
});

insomnia.test('to be json', () => {
insomnia.response.to.not.be.json;
});

insomnia.test('not error', () => {
insomnia.response.to.be.error;
});

insomnia.test("ok", function () {
	insomnia.response.to.not.be.ok;
	insomnia.expect(insomnia.response.hehe).to.be.ok;
	insomnia.response.to.be.ok;
});

insomnia.test("have 204", function () {
	insomnia.response.to.not.have.status(200);
});

insomnia.test("have 204", function () {
	insomnia.response.to.have.jsonBody("args");
});

insomnia.test("have header", function () {
	insomnia.response.to.have.header("Content-Type");
});

insomnia.test("have body", function () {
	insomnia.response.to.have.body("123");
});

insomnia.test("have body", function () {
	insomnia.response.to.have.jsonSchema({
      type: 'object',
      properties: {
        key: { type: 'integer' },
      },
      required: ['arg'],
      additionalProperties: true,
    });
});

const resp = insomnia.response.json();
insomnia.test("id not null", function () {
	insomnia.expect(resp.id).to.be.not.exists;
});

@ihexxa ihexxa self-assigned this Jul 17, 2025
@ihexxa ihexxa changed the title fix: extend insomnia.response.to assertion with chai plugin utilities fix: extend insomnia.response.to assertion with chai plugin utilities - INS-885 Jul 17, 2025
@ihexxa ihexxa changed the title fix: extend insomnia.response.to assertion with chai plugin utilities - INS-885 fix: extend insomnia.response.to assertion with chai plugin utilities - INS-944 Jul 17, 2025
@ihexxa ihexxa force-pushed the fix/sdk/resp-assert branch 2 times, most recently from 2b04a39 to ce75588 Compare July 22, 2025 02:22
@ihexxa ihexxa requested a review from a team July 23, 2025 03:05
@ihexxa ihexxa force-pushed the fix/sdk/resp-assert branch from ce75588 to e6353a2 Compare July 23, 2025 03:05
@ihexxa ihexxa merged commit 54c8bde into develop Jul 23, 2025
10 checks passed
@ihexxa ihexxa deleted the fix/sdk/resp-assert branch July 23, 2025 08:16
RoamingLost pushed a commit to RoamingLost/insomnia that referenced this pull request Aug 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants