Loading

T10 Postman · Lesson 2

Games: Collections

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 46 items in this lesson.

1 / 24

This program runs a collection against the gauges server (server.js: boiler 95, pump 40; GET /gauges, GET /gauges/:name, POST /gauges). 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: "A", item: [{ name: "a1", request: "http://localhost:3000/gauges" }] },
    { name: "b", request: "http://localhost:3000/gauges/boiler" },
    { name: "C", item: [{ name: "c1", request: "http://localhost:3000/gauges/pump" }] },
  ],
};
const server = app.listen(3000, () => {
  const names = [];
  newman.run({ collection }, () => {
    console.log(names.join(", "));
    server.close();
  }).on("beforeItem", (err, args) => names.push(args.item.name));
});
END
node app.js

Back to the lesson