# Using dynamic variable values in tests?

**URL:** <https://community.postman.com/t/using-dynamic-variable-values-in-tests/959>\
**Category:** Help Hub\
**Tags:** tests\
**Created:** [February 16, 2018, 8:13pm UTC](https://community.postman.com/t/using-dynamic-variable-values-in-tests/959 "2018-02-16T20:13:46Z")\
**Posts on this page:** 1\
**Showing post:** 13

<div class="post-metadata">

**Author:** ![ed\_truqc](https://avatars.discourse-cdn.com/v4/letter/e/ac91a4/32.png) [@ed\_truqc](https://community.postman.com/u/ed_truqc)\
**Post date:** [May 15, 2018, 11:31pm UTC](https://community.postman.com/t/using-dynamic-variable-values-in-tests/959/13 "2018-05-15T23:31:19Z")

</div>

@tmccann Thanks so much for taking the time to do this! I think I’m following what you’re doing. I added the function to my collection’s pre-request scripts section, and I added the last 2 lines (the test) to my collection’s Tests section. When I tried to run this, I had to make a couple of syntax changes (pasted below). Once I got that squared away and tried to run my collection, I got the following:

`ReferenceError: exports is not defined`

Here’s how I changed the function code. It was missing a closing brace and a closing paren:

```auto
(function () {
  'use strict';

  var exports = {};

  exports.uuid4 = function () {
    //// return uuid of form xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
    var uuid = '', ii;
    for (ii = 0; ii < 32; ii += 1) {
      switch (ii) {
      case 8:
      case 20:
        uuid += '-';
        uuid += (Math.random() * 16 | 0).toString(16);
        break;
      case 12:
        uuid += '-';
        uuid += '4';
        break;
      case 16:
        uuid += '-';
        uuid += (Math.random() * 4 | 8).toString(16);
        break;
      default:
        uuid += (Math.random() * 16 | 0).toString(16);
      }
    }
    return uuid;
  };
}
);

```

Thanks again for your time and help, I really appreciate it!

Ed

---

_[View the full topic](https://community.postman.com/t/using-dynamic-variable-values-in-tests/959)._
