Skip to content

Commit 5d56bbc

Browse files
committed
Generate test id from internal stack trace
1 parent 6385798 commit 5d56bbc

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lib/sandbox/pmapi-setup-runner.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*/
99
const _ = require('lodash'),
1010
FUNCTION = 'function',
11+
CryptoJS = require('crypto-js'),
1112
uuid = require('../vendor/uuid'),
1213

1314
OPTIONS = {
@@ -62,13 +63,12 @@ module.exports = function (pm, testsState, onAssertion) {
6263
};
6364
},
6465

65-
generateTestId = function (eventName, testName, assertFn, options) {
66-
return [
67-
eventName,
68-
testName,
69-
assertFn ? assertFn.toString() : '',
70-
JSON.stringify(options)
71-
].join('');
66+
generateTestId = function () {
67+
const stackTrace = new Error('_internal_').stack;
68+
69+
// We are creating a hash of the stack trace to generate a unique test id.
70+
// This is done to uniquely identify each test in a script irrespective of its signature
71+
return CryptoJS.SHA256(stackTrace).toString();
7272
},
7373

7474
getDefaultTestState = function (options) {

0 commit comments

Comments
 (0)