How to create a plugin
Creating a plugin starts by importing the createPlugin
function from Fluse.
This function is a generic TypeScript function that requires two generic arguments to be passed:
- a type for the plugins context shape, this represents what your plugin will add to the context. In case your plugin doesn't add anything to the context you can use the
EmptyContext
type which is exported by Fluse. - a type for runtime options that your plugin may use. These runtime options can be used to alter behaviour at runtime. They're mainly used for stateful resources such as database connections.
Once we have our plugin, we can use it by setting it up in the initialize:
Fixture definitions will now contain a key myplugin
which contains the plugins context. Additionally runtime options are now available on the execute method:
tip
If your plugin will be published as a separate npm package you should include Fluse as a peerDependency
.