In the first function, I have trolleyArray variable.I m taking an list when response returns . So this variable is an array and setting as trolleyArray variable. In the second function I want the call trolleyArray variable. But taking undifined error. How share my trolleyArray variable between to functions? If we have solution,could u write a response on my sample code
export const options = {
scenarios: {
CreatePickingStartedSalesOrders: {
executor: 'per-vu-iterations',
exec: 'CreatePickingStartedSalesOrders',
vus: 1,
iterations: 1,
startTime: '0s'
},
CreatePicking: {
startTime: '45s',
exec: 'CreatePicking',
executor: 'shared-iterations',
vus: 2,
iterations: 1,
maxDuration: '50s',
},
}
}
var trolleyArray;
export function CreatePickingStartedSalesOrders(data) {
let createPickingStartedSalesOrdersHeader = {
headers: {
"api": "testtt",
"Content-Type":"application/json"
},
};
describe('PickingInProgress', (t) => {
let createSalesOrdersRes = http.post(requestUrlSeed + 'CreateOrders', JSON.stringify({
salesOrderConfigurations: [
{
referencePrefix: 'XL-',
flow: 'MultiItem',
}
],
tenant: 'SpeedyLojistik',
operation: 'Rossmann'
}), createPickingStartedSalesOrdersHeader)
trolleyArray= createSalesOrdersRes.json()
t.expect(createSalesOrdersRes.status).toEqual(200);
});
}
export function CreatePicking(data) {
let generateTokenHeader = {
headers: {
'Authorization': `Bearer ${data.access_token}`,
'content-type': 'application/json',
},
};
describe('Picking', (t) => {
let continueRes = http.post(requestUrlAPI + 'PickingProcess.continueExist', JSON.stringify({
trolleyLabel: trolleyArray[exec.vu.idInTest]
}), generateTokenHeader
t.expect(continueRes .status).toEqual(200);
sleep(1)