Skip to main content

Function: installGlobalPlugin()

installGlobalPlugin(plugin, position?): void

Defined in: packages/fast-check/src/check/runner/configuration/GlobalPlugins.ts:35

Install a plugin to be used by all the runners

Pre-installed plugins (the default) come before the ones passed via the plugins option of the run. Post-installed ones come after but before the default plugins.

Set noGlobalPlugins: true to skip them for a particular run.

In other words, pre-installed plugins are the outermost ones: they are entered first when running the predicate. Think of: pre(local(post(default(predicate)))).

Parameters​

ParameterTypeDefault valueDescription
pluginUniversalPlugin | Plugin<unknown>undefinedPlugin to be installed globally
position?"pre" | "post"'pre'Install before ('pre', the default) or after ('post') the plugins passed to the runner

Returns​

void

Example​

fc.installGlobalPlugin(myPrePlugin1());
fc.installGlobalPlugin(myPostPlugin1(), 'post');
fc.installGlobalPlugin(myPrePlugin2());
fc.installGlobalPlugin(myPostPlugin2(), 'post');
//...
fc.assert(myProp, { plugins: [myOtherPlugin()] })
// Plugin order: myPrePlugin1, myPrePlugin2, myOtherPlugin, myPostPlugin1, myPostPlugin2, followed by default plugins.
// Each plugin wraps the plugins that follow it, so myPrePlugin1 is the outermost wrapper.
// Pass `noGlobalPlugins: true` to skip global plugins or `noDefaultPlugins: true` for default ones.

Remarks​

Since 4.10.0