Mock20
A node.js module that mocks the Roll20 API environment.
For an exmple Roll20 project that uses Mock20, see Example Mock20 Testing.
Installation
-
Get node and npm.
-
Turn your scripts into a node module.
-
Add mock20 as a dependency.
npm install mock20
-
Require mock20 and signal the end of your scripts.
require('mock20'); //your script here MOCK20endOfLastScript(); //triggers all of your on('ready') functions
Mocking
Mock20 mocks all of the functions listed in the Roll20 API wiki.
See the wiki for more information.
- API:Objects
- API:Events
- API:Chat
- WARNING: The current version of Mock20 does not parse rolls like
'/r D20'
- WARNING: The current version of Mock20 does not parse inlines like
'Rolls a [[D20]]'
- WARNING: The current version of Mock20 does not parse rolls like
- API:Utility
Simulating
Mock20 can simulate circumstances you may want to test.
See the wiki for more information.
var player = createObj('player', {_displayname: 'test player'}, {MOCK20override: true});
var gm = createObj('player', {_displayname: 'test gm'}, {MOCK20override: true});
gm.MOCK20gm = true;
player.MOCK20chat('!gmOnlyCMD');
gm.MOCK20chat('!gmOnlyCMD');
Issues
If you have any issues with Mock20 please report them through github's issues.
Contributing
If you would like to contribute to the project, open up a fork and work away.