
John M.'s debugging post inspired me to post what I've been using for the past couple months.
Here is a sample of how you can set up automated tests to execute your scripts outside of roll20.
This assumes you are familiar with writing automated tests with mock objects. Creating automated tests is large topic beyond the scope of this post.
I'm using the javascript test framework Jasmine http://pivotal.github.io/jasmine/ version 1.3.0 (download here) along with an extension jasmine-stealth https://github.com/searls/jasmine-stealth version 0.0.12
First you'll need to acquire Jasmine and the extension mention jasmine-stealth. If you use underscore commands in you scripts you'll also need to get that at http://underscorejs.org/ I'm using version 1.5.2. I'm not sure which version roll20 is actually using.
Next you need to set up a html spec file. Example:
https://github.com/davout1806/roll20/blob/master/SpecRunner.html
My directory structure it might help you understand the relative directories in the HTML file
project\main
project\main\prod - where my scripts are located
project\main\testing - where Roll20Mock is located
project\tests - where test scripts and HTML spec files are located
project\tests\lib - where jasmine and underscore files are located
Then you'll need to set up your tests in javascript file(s). Example file (one of my test files):
https://github.com/davout1806/roll20/blob/master/ConditionsTest.js
Finally, just load your html spec file in a browser and your tests will run.
FWIW when I need to debug my code I use firebug, which allows breakpoints and inspection of variable values.
If you have questions I'll try to answer as best I can.
Please note I consider myself lower-intermediate level javascript developer. So if anyone has suggestions on improvement please feel free to drop a line.
Contents of Roll20Mock.js
Add function declarations as needed.
https://github.com/davout1806/roll20/blob/master/Roll20Mock.js
Here is a sample of how you can set up automated tests to execute your scripts outside of roll20.
This assumes you are familiar with writing automated tests with mock objects. Creating automated tests is large topic beyond the scope of this post.
I'm using the javascript test framework Jasmine http://pivotal.github.io/jasmine/ version 1.3.0 (download here) along with an extension jasmine-stealth https://github.com/searls/jasmine-stealth version 0.0.12
First you'll need to acquire Jasmine and the extension mention jasmine-stealth. If you use underscore commands in you scripts you'll also need to get that at http://underscorejs.org/ I'm using version 1.5.2. I'm not sure which version roll20 is actually using.
Next you need to set up a html spec file. Example:
https://github.com/davout1806/roll20/blob/master/SpecRunner.html
My directory structure it might help you understand the relative directories in the HTML file
project\main
project\main\prod - where my scripts are located
project\main\testing - where Roll20Mock is located
project\tests - where test scripts and HTML spec files are located
project\tests\lib - where jasmine and underscore files are located
Then you'll need to set up your tests in javascript file(s). Example file (one of my test files):
https://github.com/davout1806/roll20/blob/master/ConditionsTest.js
Finally, just load your html spec file in a browser and your tests will run.
FWIW when I need to debug my code I use firebug, which allows breakpoints and inspection of variable values.
If you have questions I'll try to answer as best I can.
Please note I consider myself lower-intermediate level javascript developer. So if anyone has suggestions on improvement please feel free to drop a line.
Contents of Roll20Mock.js
Add function declarations as needed.
https://github.com/davout1806/roll20/blob/master/Roll20Mock.js