Postman-to-k6 Script Does Not Run

I’m afraid I’ve had no luck getting a k6 script to run when created from a postman collection. I consistently get the same error message:

only supported schemes for imports are file and https, *{file_location}/*script.js has c

I made the simplest collection that I could think of, the error is still present. Please see code:

// Auto-generated by the postman-to-k6 converter

import "./libs/shim/core.js";

export let options = { maxRedirects: 4 };

const Request = Symbol.for("request");
postman[Symbol.for("initial")]({
  options
});

export default function() {
  postman[Request]({
    name: "FiveThirtyEight",
    id: "b566def9-deca-4788-8276-255b3ab28e69",
    method: "GET",
    address: "https://fivethirtyeight.com/",
    post(response) {
      pm.test("Status code is 200", function() {
        pm.response.to.have.status(200);
      });
    }
  });
}

Any help would be greatly appreciated.

Hi @hvincent44 , Welcome to the community forum :tada:

The error and script you are providing doesn’t make sense. Unless core.js does import something, which IIRC wasn’t true.

What version of postman-to-k6 are you using? The original project has been deprecated and a community member has forked it. I myself have no idea whether something hasn’t changed drastically with the fork.

Maybe @thim81 can weight in and give us a hand :bowing_man:

@hvincent44 We never ran into that error message.

Could you indeed share which version of the postman-to-k6 converter you are using?

Certainly, its 1.8.3. I will check out the forked repo @mystoykov; if the solution is as simple as changing a dependency, I will be incredibly relieved!

The generated k6-scripts.js seems like to output that would be expected.

Could you also check which version of K6 you are using?

Certainly; probably should have mentioned it earlier, but I’m running k6 in Docker with the image pointed to the latest version of k6.

@hvincent44 can you paste how you are running it?

Sure;

docker run -v C://Users//heath.vincent//k6//node_modules://node_modules -i loadimpact/k6 run  C://Users//heath.vincent//k6//k6.js

. The double slashes apparently are necessary for windows machines, before adding them I got an error indicating the files could not be found.

@hvincent44 Would you be able to share the Postman collection? Or the generated K6 script? So we can try to reproduce it locally?

Sure; the postman collection is a simple get request to fivethirtyeight.com, just to figure out what’s going on:

{
	"info": {
		"_postman_id": "b2a64751-f9d2-4329-8394-cd028deb368c",
		"name": "Test",
		"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
	},
	"item": [
		{
			"name": "FiveThirtyEight",
			"event": [
				{
					"listen": "test",
					"script": {
						"exec": [
							"pm.test(\"Status code is 200\", function () {\r",
							"    pm.response.to.have.status(200);\r",
							"});"
						],
						"type": "text/javascript"
					}
				}
			],
			"request": {
				"method": "GET",
				"header": [],
				"url": {
					"raw": "https://fivethirtyeight.com/",
					"protocol": "https",
					"host": [
						"fivethirtyeight",
						"com"
					],
					"path": [
						""
					]
				}
			},
			"response": []
		}
	]
}

Navigating the the folder location and running

postman-to-k6 Test.postman_collection.json -o script.js

results in the following generated file (with node_modules folder created in the same location):

// Auto-generated by the postman-to-k6 converter

import "./libs/shim/core.js";

export let options = { maxRedirects: 4 };

const Request = Symbol.for("request");
postman[Symbol.for("initial")]({
  options
});

export default function() {
  postman[Request]({
    name: "FiveThirtyEight",
    id: "f1c9e63a-61a9-4bee-9dd0-2cea0671b695",
    method: "GET",
    address: "https://fivethirtyeight.com/",
    post(response) {
      pm.test("Status code is 200", function() {
        pm.response.to.have.status(200);
      });
    }
  });
}

From there, its just a matter of loading up the Docker image and running:

docker run -v C://Users//heath.vincent//k6//node_modules://node_modules -i loadimpact/k6 run  C://Users//heath.vincent//k6//k6.js```

Hi @hvincent44

It seems to be linked to the K6 Docker you are using.
I have the K6 binary installed and this is the result:

postman.json

script.js

K6 run

Perhaps you can try to install the K6 binary direct and use it instead of the Docker?

@hvincent44 this seems to me to be related to your usage of docker.

You are mounting only node_modules which I am not certain is even needed in this case but then ask k6 to run file C://..... Which definitely won’t be mounted inside the docker from what I can see. But even if you did this definitely looks like a URL with scheme C.

I don’t know in practice anything about docker on windows, so can’t really help you, but this seems to be a problem with that or it’s usage more accurately. Instead of with postman-to-k6.

Thanks @thim81 :bowing_man: , but unless you know how to work with docker on windows I think I mostly wasted your time as this definitely doesn’t seem like a problem with postman-to-k6