Open ericmacfa opened 7 years ago
Trial and error yielded an answer: Assuming your project structure looks something like this
project_root ($ for brevity)
| package.json
+---MyPlugin/
| index.js
+---tests/
| example-test.yml
+---util/
| request-utils.js
You can get Artillery to load a plugin from $/MyPlugin/
with the below yml config:
config:
plugins:
MyPlugin:
scope: '../../../' # This path gets loaded relative to $/node_modules/artillery-core/lib/runner.js
The key detail being the scope
property in the plugin's config.
Without the scope
set, Artillery will simply require
a module with the name artillery-plugin-MyPlugin
Setting the scope
lets us change the prefix that Artillery uses to require the plugin, and we can point it at a local dir.
Re-opening as this needs to be documented (and plugins in general).
Thanks @ericmacfa
It would be great to allow a plugin to self-test by including a yaml file in the plugin source, and load the plugin from the same directory.
However even with scope, this seems impossible, as it's doing a simple string concatenation.
How do people feel about there being a path
attribute for plugins, which would allow:
config:
plugins:
myPlugin: {
path: './index.js'
}
This would solve local plugin paths as well, so it might be possible to do away with the (imho less flexible) scope attribute.
Thoughts?
I did see the plugin docs.
I looks like plugins can easily be added to a config, as long as they're installed as a module dependency (so they can be
require()
d by module name).Is it possible to tell the plugin loader to load the plugin from a local directory instead?