Skip to content
This repository has been archived by the owner on Nov 23, 2021. It is now read-only.

Updated 'Environment variable' in 'Request.Pre' was not updated in the request body. #76

Closed
Auttasak-L opened this issue Dec 17, 2020 · 3 comments

Comments

@Auttasak-L
Copy link

I found that the updated value of variable 'counter'
in 'pm.environment' was not be replaced correctly
in the 'request body'.

Environment

  • k6 version: k6 v0.29.0 (2020-11-11T13:27:03+0000/d9bced3, go1.15.4, linux/amd64)
  • OS and version: WSL2 Ubuntu-20.04

Expected Behavior

Value of 'counter' that was set in
the 'pm.environment' variable
should be replaced correctly in
the sent request data.

Actual Behavior

The 'counter' value of first '/echo/'
request is 'undefined'.

Steps to Reproduce the Problem

  1. k6 run test.js

To fix this

  1. I found that the problem is in below function
    at the commented line (line contains pm[Var])
    which can be fixed by replace it with
    'pm.environment.get'.

    function evaluate(string) {
    // return string.replace(expression.variables, (match, name) => pm[Var](name));
    return string.replace(expression.variables, (match, name) => pm.environment.get(name));
    }

test.js.txt

@imiric
Copy link

imiric commented Dec 17, 2020

Hi, thanks for reporting this.

This seems like an issue with the generated code from the postman-to-k6 tool. Would you mind creating an issue there?

Before you do that, make sure you're using the latest version to convert the Postman collection.

@imiric imiric closed this as completed Dec 17, 2020
@na-- na-- transferred this issue from grafana/k6 Jan 4, 2021
@na--
Copy link
Member

na-- commented Jan 4, 2021

I saw that this wasn't recreated, so I moved the whole issue 😅

@ppcano
Copy link
Collaborator

ppcano commented Nov 22, 2021

Apologies for the inactivity on this project.

Due to the inability to properly support this project, the k6 team has decided not to continue its development. The primary reason is that k6 scope has grown significantly with the launch of k6 extensions. The team is prioritizing extending k6 capabilities over the converters.

We suggest you post your issue at api-deck/postman-to-k6. The project is active and maintained on this fork.

@ppcano ppcano closed this as completed Nov 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants