Hey,
I am getting an error when passing a Trend to a function. We have a common functions file where we have API calls, and want to pass in pre-defined trends from different files, so that we can add different combinations of tests and use a common file for them all.
when passing in the trend like so, I am getting a “TypeError: Cannot read property ‘add’ of undefined or null”.
We are doing something of the following:
test1.js
export const tc1_trends = new Trend('TC1_Trend');
export function test_case_1 (url) {
group('Run TC 1', function() {
testCase(url, tc1_trends );
});
}
common.js
export function testCase(url , trend) {
let res = http.post(`${url});
check(res , { "status is 200": (r) => r.status === 200, });
trend.add(res .timings.duration);
};
if there’s a better way, that doesn’t involve polluting the “common.js” file with the trend definitions please let me know.
thank you!