Skip to content

Commit

Permalink
Generate test id from internal stack trace
Browse files Browse the repository at this point in the history
  • Loading branch information
appurva21 committed Jun 6, 2023
1 parent 6385798 commit 5d56bbc
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/sandbox/pmapi-setup-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/
const _ = require('lodash'),
FUNCTION = 'function',
CryptoJS = require('crypto-js'),
uuid = require('../vendor/uuid'),

OPTIONS = {
Expand Down Expand Up @@ -62,13 +63,12 @@ module.exports = function (pm, testsState, onAssertion) {
};
},

generateTestId = function (eventName, testName, assertFn, options) {
return [
eventName,
testName,
assertFn ? assertFn.toString() : '',
JSON.stringify(options)
].join('');
generateTestId = function () {
const stackTrace = new Error('_internal_').stack;

// We are creating a hash of the stack trace to generate a unique test id.
// This is done to uniquely identify each test in a script irrespective of its signature
return CryptoJS.SHA256(stackTrace).toString();
},

getDefaultTestState = function (options) {
Expand Down

0 comments on commit 5d56bbc

Please sign in to comment.