3

what version of JavaScript is allowed in Postman test script?

I tried to look this up from Postman's document but the answer is not obvious. For example, I looked at the official document of Postman Sandbox Execution Environment

leeyuiwah
  • 6,562
  • 8
  • 41
  • 71
  • Is there a specific reason for knowing? – Danny Dainton Dec 30 '18 at 22:02
  • 1
    @Danny -- Just for completeness. For example, I want to make sure that I would not be using syntax in later versions of JavaScript that is not accepted by `Postman` – leeyuiwah Dec 31 '18 at 09:41
  • There's a sure fire way to find out... :) I use `const`, `let` and arrow functions etc. Not sure what version those are part of but it's a starting point. You could have a play around to see what does and doesn't work. – Danny Dainton Dec 31 '18 at 13:52
  • @Danny -- Yes I know I can "reverse engineer" the version number. But I just think it is better if the supported version is documented. They already document the JavaScript libraries allowed in the sandbox environment. Just wonder why they do not also document the supported JavaScript version. – leeyuiwah Dec 31 '18 at 14:56
  • 1
    What if it did and the documentation was out of date? :) This seems like a very specific question that might be worth asking in the place where you would get a specific answer - https://community.getpostman.com/t/welcome-to-discourse/8 – Danny Dainton Dec 31 '18 at 17:36
  • @Danny -- Okay thanks! I posted a message to Postman Community – leeyuiwah Dec 31 '18 at 17:42

1 Answers1

0

I've put some code together in order to display the java script version into the postman's visualizer - I could not figure out a way to get the value.

write this script below at your request "Test" (any request will suffice):

    var template=`
    <script language="javascript">var js_version="1.0"</script>
    <script language="javascript1.1">var js_version="1.1"</script>
    <script language="javascript1.2">var js_version="1.2"</script>
    <script language="javascript1.3">var js_version="1.3"</script>
    <script language="javascript1.4">var js_version="1.4"</script>
    <script language="javascript1.5">var js_version="1.5"</script>
    <script language="javascript1.6">var js_version="1.6"</script>
    <script language="javascript1.7">var js_version="1.7"</script>
    <script language="javascript1.8">var js_version="1.8"</script>
    <script language="javascript1.9">var js_version="1.9"</script>
    assuming that visualizer uses the SAME script engine version used by postman: 
    <script language="javascript">
      document.write(js_version); 
    </script>
    `;
    pm.visualizer.set(template);

the version info will be displayed at the visualize tab into the body tab.

JoSSte
  • 2,953
  • 6
  • 34
  • 54
agodinhost
  • 381
  • 4
  • 16