komondor-plugin
Library to create plugins for komondor
.
Usage
To create a plugin, you need to export a activate()
function as follow:
The Spy
is used to record the actions performed,
while the Stub
is used to replay the actions recorded.
API
Registrar.register(name, support, getSpy, getStub)
Register a plugin.
name: string
Name of the plugin.
The name should be unique. If consumer loads two plugins with the same name, an error will be thrown.
This name should be used as the scope name of your actions.
For example, if your plugin is node
which as childProcess
and stream
,
then your action types should be node/childProcess
, node/stream
, etc.
support: subject => boolean
A predicate to determine if the plugin supports the subject
.
For example, for the generic function
plugin,
the predicate is subject => typeof subject === 'function'
.
getSpy: (context, subject) => spiedSubject
Creates a spied subject.
getStub: (context, subject) => stubbedSubject
Creates a stubbed subject.
createExpectation(type: string, name: string): (payload, meta?) => SpecExpectation
SpecExpectation
is a partial SpecAction
to be used in a the spec.satisfy()
call.
Use this function to create helper functions for the user to create their expectations easily.
createScopedCreateExpectation(scopy: string): (subType: string, name: string) => (payload, meta?) => SpecExpectation
Create a scoped createExpectation()
.
Helper
When writing your plugin, you can consider using komondor-test
to help testing your plugin.
When testing your plugin,
you can use speced.satisfy([...])
instead of speced.done()
to ensure the actions are recorded properly.
Contribute
# right after fork npm install # begin making changes git checkout -b <branch>npm run watch # edit `webpack.config.dev.js` to exclude dependencies for the global build. # after making change(s) git commit -m "<commit message>"git push # create PR
Npm Commands
There are a few useful commands you can use during development.
# Run tests (and lint) automatically whenever you save a file. npm run watch # Run tests with coverage stats (but won't fail you if coverage does not meet criteria) npm run test # Manually verify the project. # This will be ran during 'npm preversion' so you normally don't need to run this yourself. npm run verify # Build the project. # You normally don't need to do this. npm run build # Run tslint # You normally don't need to do this as `npm run watch` and `npm version` will automatically run lint for you. npm run lint
Generated by generator-unional@0.0.1