Using dynamic variable values in tests?

@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:

(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