[postman-to-k6] Postman global variables pm.globals

I tried to mimic what you’re doing @Murat and the following script works for me with latest version of postman-to-k6. It prints Yours Truly in the terminal as expected. If you you can’t get your script working with the latest version of the converter then please file an issue in github as suggested by @mstoykov.

import { group } from "k6";
import "./libs/shim/core.js";
import "./libs/shim/expect.js";

const Request = Symbol.for("request");

export default function() {
 group('Get slideshow author', function() {
    postman[Request]({
      name: "Get JSON",
      method: "GET",
      address: `https://httpbin.org/json`,
      post(response) {
        pm.test("Get JSON returns Status code 200", function() {
          pm.response.to.have.status(200);
        });
  
        pm.test("Response contains author", function() {
          pm
            .expect(pm.response.json().slideshow.author)
            .to.be.an("string").that.is.not.empty;
  
          var author = pm.response.json().slideshow.author;
          pm.globals.set("slideshowAuthor", author);
        });
      }
    });

    let slideshowAuthor = pm.globals.get('slideshowAuthor');
    console.log(slideshowAuthor);
  });
}