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

Extend support for Postman random functions/dynamic variables/replaceIn #92

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

thim81
Copy link
Contributor

@thim81 thim81 commented May 4, 2021

Currently the package supports 3 random Postman functions.

  /* Version 4 GUID */
  guid() {
    return guid();
  },

  /* Random integer [0,1000] */
  randomInt() {
    return Math.floor(Math.random() * 1001);
  },

  /* Current time as Unix timestamp */
  timestamp() {
    return Date.now();
  }

This PR is is to extend the support for all current Postman dynamic variables
https://learning.postman.com/docs/writing-scripts/script-references/variables-list/

#91

@thim81
Copy link
Contributor Author

thim81 commented May 4, 2021

hi @simskij

I think I solved it BUT I needed to manually add a "faker.js" file in the shim folder,
Which is a copy of "https://raw.githubusercontent.com/Marak/faker.js/9c65e5dd4902dbdf12088c36c098a9d7958afe09/dist/faker.min.js". since I couldn't get it to work using the bundle.js script and by including faker in the packages.json file.

I reference the dynamic variable functions through an import in the "core.js" file, which might not be the desired convention.

Looking forward to receive remarks or improvements or even rejection if you don't think the PR is suitable.

The goal of this PR was to provide support for all Postman dynamic variables.

@simskij simskij self-requested a review May 5, 2021 10:18
@thim81 thim81 mentioned this pull request May 7, 2021
@thim81
Copy link
Contributor Author

thim81 commented May 24, 2021

@simskij did you had some time to review to PR?

Don't be overwhelmed by the amount code because this is mostly due to the 2 files that were added:

  • faker.js
  • port of the Dynamic variable functions directly from Postman

@ghost
Copy link

ghost commented Jul 23, 2021

@thim81 some update about this PR?

@thim81
Copy link
Contributor Author

thim81 commented Jul 24, 2021

@dbacelar4i No news on the PR, still hoping from some feedback from the expert @simskij.

I have been using the PR branch beginning of May 2021 and it works BUT I'm not sure if it is implemented in the correct way.

What I'll do, is I'll prepare a 1.6.0 branch will combine this PR, together with the other open PR's and share it here, so that you can try it also yourself.

thim81 pushed a commit to thim81/postman-to-k6 that referenced this pull request Jul 24, 2021
@thim81
Copy link
Contributor Author

thim81 commented Jul 24, 2021

@dbacelar4i

I have bundled all the open functional PR's (#92 / #103 / #113) in a 1.6.0 release branch >> https://github.com/thim81/postman-to-k6/tree/release.1.6.0

You should be able to pull it in your packages.json and use the latest code in your node project, while we wait for one of the maintainers to review the pending PR's.

Example of packages.json:

  "dependencies": {
    "postman-to-k6": "git+https://github.com/thim81/postman-to-k6#release.1.6.0"
  }

@thim81
Copy link
Contributor Author

thim81 commented Jul 24, 2021

PR is also linked to #90

@thim81
Copy link
Contributor Author

thim81 commented Jul 30, 2021

@simskij with the acquisition by Grafana, what will happen with the postman-to-k6 package? And is there something we can help with?

@thim81 thim81 changed the title Extend support for Postman random functions/dynamic variables Extend support for Postman random functions/dynamic variables/replaceIn Aug 15, 2021
@thim81
Copy link
Contributor Author

thim81 commented Aug 15, 2021

Support for the usage of the replaceIn method was added, thanks to the contribution of @gfeun.

@gfeun
Copy link

gfeun commented Aug 16, 2021

Thanks Thim !

I'll be watching this space in case changes are needed after review.

thim81 referenced this pull request in apideck-libraries/postman-to-k6 Aug 17, 2021
* Extend support for Postman random functions/dynamic variables (#92)

* Fix for unwanted encoding of Postman variables in query string, but keep support for "space" (#113)

* Exclude disabled headers when converting requests (#103)

* Implement postman replaceIn function

* Extended test for url encode handling

* Extended test for url encoding of space characters

* Extended test to exclude disabled headers when converting requests (#103)

* Extended test to include checks for randomPhoneNumber & isoTimestamp

* Updated GH workflow actions

Co-authored-by: Tim <>
@thim81
Copy link
Contributor Author

thim81 commented Sep 1, 2021

For those missing this functionality, I have provided a forked NPM package version that contains the Postman dynamic variables functionality:

Replace in your packages.json:

"dependencies": {
    "postman-to-k6": "^1.5.0"
  }

to

"dependencies": {
    "@apideck/postman-to-k6": "^1.7.0"
  }

This is a forked NPM package, to facilitate other users. The current maintainers are quite overloaded by the acquisition of K6 by Grafana. By forking the repo & package, users can keep using new PR's & (security) fixes. At a later stage the changes can potentially be merged back in the original postman-to-k6 repo.

The changelog contains the differences between the original package & the forked version.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants