Artillery - script.scenarios.forEach is not a function

999 Views Asked by At

I am new to Artillery and stuck in basic flow, I am getting following issue:-

artillery run test_load.yaml

/usr/local/lib/node_modules/artillery/lib/commands/run.js:315
  script.scenarios.forEach(function(scenario) {
                   ^

TypeError: script.scenarios.forEach is not a function
    at checkIfXPathIsUsed (/usr/local/lib/node_modules/artillery/lib/commands/run.js:315:20)
    at fn (/usr/local/lib/node_modules/artillery/node_modules/async/lib/async.js:746:34)
    at /usr/local/lib/node_modules/artillery/node_modules/async/lib/async.js:1213:16
    at /usr/local/lib/node_modules/artillery/node_modules/async/lib/async.js:166:37
    at /usr/local/lib/node_modules/artillery/node_modules/async/lib/async.js:706:43
    at /usr/local/lib/node_modules/artillery/node_modules/async/lib/async.js:167:37
    at Immediate._onImmediate (/usr/local/lib/node_modules/artillery/node_modules/async/lib/async.js:1206:34)
    at runCallback (timers.js:794:20)
    at tryOnImmediate (timers.js:752:5)
    at processImmediate [as _immediateCallback] (timers.js:729:5)

yml file:-

config:
  http:
  target: 'https://sit-api.XX.com'
  phases:
    duration: 60
    arrivalRate: 20
  defaults:
    headers:
      Authorization: "Basic XXXX=="
scenarios:
  flow:
    post:
      url: '/XX/v1/XX?apikey=XX'
      sslAuth: false
      json:
        siteId: '132'
        orderId: '2220000666'
        productId: '102793419'
        timestamp: '202021-11-26T10:20.36'
        pickTaskId: 'XXX-XX-XX-8e6f135-Yj9Rw1n35'
        pickLocationId: 'U-XX-3'
        quantityPicked: 21.1
        quantityOrdered: 20.491
    expect:
      statusCode: 202

I am running this throw terminal using the following command :- artillery run test_load.yaml

1

There are 1 best solutions below

1
On

As per documentation you need to list your scenarios:

scenarios:
  - flow:

You are missing "-" before the keyword "flow"

https://artillery.io/docs/guides/guides/test-script-reference.html#Overview