Regarding Collection level pre scripts #1401
Replies: 4 comments
-
Hi @altereddie We have two ways of writing scripts If you need reusable functions then you can try External JS files above You can also use both scripts features above. Let me know your feedback. |
Beta Was this translation helpful? Give feedback.
-
Import functions from other js files in ScriptsJust now implemented this feature - Now you can import as below in the next update (ETA - Monday) async function testFunc () {
console.log ("Test log message");
return "TEST";
}
module.exports = [testFunc]; in this collection there is one testx api inside that i put tests script as following const [testFunc] = require("test.js");
const result = await testFunc();
console.log(result); // TEST
console.log('test hello') |
Beta Was this translation helpful? Give feedback.
-
@rangav |
Beta Was this translation helpful? Give feedback.
-
This feature is implemented and published to the marketplace, please update to See all features in this update Please test and let me know your feedback. |
Beta Was this translation helpful? Give feedback.
-
So i am trying to replicate our requirement into thunder client from postman.
So we have script at collection level in postman, and we are using that pre script into api level pre script
Attaching code for better understanding
test(collection) > testx(api)
POSTMAN
test (collection) inside pre-request script section
utils = { myFunc: function () { return 'hello'; } };
and in testx(api) inside pre script section
console.log(utils.myFunc()); // hello
and it works
now in THUNDER CLIENT
test (collection) inside pre-run scripting section
utils = { myFunc: function () { return 'hello'; } };
and in testx(api) inside pre scripting section
console.log(utils.myFunc()); // hello
and this thing dont work.
can you look into it and guide me ?
Beta Was this translation helpful? Give feedback.
All reactions