Automatically create test for current response

Usually, when I’m writing tests, I already have correctly working HTTP endpoints. It means, when I click the “Send” in postman, the response is correct or sometimes almost correct. So I want to commit the current behaviour with tests. So most often I just write assertions for current response.

So my suggestion is next.

Let say, I have some endpoint, GET When I send it, the server produces the response:

200 Ok
  "userId": 1,
  "id": 1,
  "title": "delectus aut autem",
  "completed": false

I want to have a button, maybe in the SNIPPETS panel, maybe named “Assertion for current response”, that will generate the next test:

pm.test("Status code is 200", function () {;

pm.test("Body is correct", function () {;
    const response = pm.response.json();
    pm.expect(response.title).to.eql("delectus aut autem");
1 Like

I like this feature, it would be cool if we could add our own snippets in Postman