Loading

T10 Postman · Lesson 4

Games: Tests in Postman

Choose the right option, fill in the blanks, write small pieces of code and fix broken ones. Code runs in a safe box inside this page.

Solved 0 of 45 items in this lesson.

1 / 23

This program tests one answer of the gauges server (server.js: GET /gauges answers [boiler 95 C, pump 40 bar]; GET /gauges/:name one gauge or 404; POST /gauges answers 201, or 400 when value is not a number). What does it print?

cat > app.js <<'END'
const newman = require("newman");
const app = require("./server");
const collection = {
  info: { name: "Engine Hall gauges" },
  item: [
    {
      name: "the request",
      request: "http://localhost:3000/gauges/boiler",
      event: [{ listen: "test", script: { exec: [
        'pm.test("hot", () => pm.expect(pm.response.json().value).to.be.above(100));',
      ] } }],
    },
  ],
};
const server = app.listen(3000, () => {
  newman.run({ collection }, () => server.close())
    .on("assertion", (err, args) => console.log(args.assertion + ": " + (err ? err.message : "passed")));
});
END
node app.js

Back to the lesson