2

I'm quite new to the artillery.io and I'm getting a problem. I want to get a value from the JSON response and check it on the 'expect' clause, so I'm doing that like this:

config:
  target: 'https://api.duckduckgo.com'
  plugins:
      expect: {}
  phases:
    - duration: 1
      arrivalRate: 1
scenarios:
   - flow:
      - get:
          url: "/?q=cao&format=json"
          capture:
            - json: $RelatedTopics[0].FirstURL
              as: url
          expect:
            - statusCode: 200
            - equals:
              - "{{ url }}"
              - "https://duckduckgo.com/209/Cao_Wei"
      - log: "url is {{ url }}"

Then I call the artillery just like this:

artillery run duck.yml

Then I get something like this:

User variables:
     target : https://api.duckduckgo.com
     $environment : undefined
     $uuid : 0774da00-b6e6-415c-bd28-0ff4bedd07ec
  not ok equals , https://duckduckgo.com/209/Cao_Wei 
  expected: all values to be equal
       got: , https://duckduckgo.com/209/Cao_Wei
  Request params:
    https://api.duckduckgo.com/?q=cao&format=json
    ""

I omitted the rest of the output cause it is too big. When it says "not ok equals , https://duckduckgo.com/209/Cao_Wei" looks like to me that my url variable is undefined.

Using the JSONPath on quotes like this "$RelatedTopics[0].FirstURL" gives the same problem.

I installed the expect (https://artillery.io/docs/plugin-expectations-assertions/) plugin like this:

npm install -g artillery-plugin-expect

Please, what am I missing here?

Rodolfo
  • 1,091
  • 3
  • 13
  • 35

1 Answers1

0

The problem should go away if you upgrade to the most recent version (1.2.1) of the plugin, earlier versions had a bug in equals comparisons involving captured variables (reference: https://github.com/artilleryio/artillery-plugin-expect/pull/4)