
Security News
NVD Concedes Inability to Keep Pace with Surging CVE Disclosures in 2025
Security experts warn that recent classification changes obscure the true scope of the NVD backlog as CVE volume hits all-time highs.
artillery-plugin-expect
Advanced tools
artillery
command to run functional / acceptance tests on your APIsš Please report issues over at https://github.com/shoreditch-ops/artillery/issues
npm install -g artillery-plugin-expect
Important: this plugin requires Artillery v1.6.0-26
or higher.
config:
target: "http://example.com"
plugins:
expect: {}
scenarios:
- name: Get pets
flow:
- get:
url: "/pets"
capture:
- json: "$.name"
as: name
expect:
- statusCode: 200
- contentType: json
- hasProperty: results
- equals:
- "Tiki"
- "{{ name }}"
Run your script that uses expectations with:
artillery run --quiet my-script.yaml
The --quiet
option is to stop Artillery from printing its default reports to the console.
Failed expectations provide request and response details:
This plugin allows for the same scenario to be re-used for either load testing or functional testing of an API. (The only real difference between the two, of course, is how many virtual users you run -- only one for functional tests, and $BIG_NUMBER
for a load test.)
In practical terms, what you probably want to do is use the environments
functionality in Artillery to create a separate "environment" with configuration for functional testing. Something like:
config:
target: "https://my.api.internal"
environments:
#
# This is our load testing profile, where we create a lot of virtual users.
# Note that we don't load the plugin here, so that we don't see the output
# from the plugin.
#
load:
phases:
- duration: 600
arrivalRate: 10
#
# This is our functional testing profile, with a single virtual user, and
# the plugin enabled.
#
functional:
phases:
- duration: 1
arrivalCount: 1
plugins:
expect: {}
scenarios:
# Your scenario definitions go here.
statusCode
Check that the response status code equals the code given.
expect:
- statusCode: 201
contentType
Check the value of Content-Type
header.
hasProperty
When the response is JSON, check that the response object has a property. Same as lodash#has
.
expect:
- hasProperty: 'data[0].id'
equals
Check that two or more values are the same. NOTE only primitive values (e.g. booleans, strings and numbers) are currently supported.
- get:
url: "/pets/f037ed9a"
capture:
- json: "$.species"
as: species
expect:
- equals:
- "{{ species }}"
- "dog"
This plugin is still in the early stages and we would love to hear your comments, ideas and suggestions for improvements. Please file an issue over at https://github.com/shoreditch-ops/artillery/issues.
MPL 2.0
FAQs
Expectations and assertions for HTTP scenarios
The npm package artillery-plugin-expect receives a total of 67,833 weekly downloads. As such, artillery-plugin-expect popularity was classified as popular.
We found that artillery-plugin-expect demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Security experts warn that recent classification changes obscure the true scope of the NVD backlog as CVE volume hits all-time highs.
Security Fundamentals
Attackers use obfuscation to hide malware in open source packages. Learn how to spot these techniques across npm, PyPI, Maven, and more.
Security News
Join Socket for exclusive networking events, rooftop gatherings, and one-on-one meetings during BSidesSF and RSA 2025 in San Francisco.