Moves unit tests into the repo and makes them run 8 times faster#24
Conversation
By setting the Durartion option to 1 the tests run about 8 times faster. This commit also adds unit tests fot the Button and MonthFormat option.
input field again.
…nimation:'none' was used
|
WOW Benjamin! Exactly what we needed here. Give me some time to play with this and get used to it, verify everything is working as expected, then I will probably merge here soon! I can't wait to get started, this is going to be fun! Woot! |
|
This is very professional work Benjamin! I am very impressed. I like the way that the unit tests are separated from the demo now, I love the headless testing too. I really like the way your new menus work by setting the animation to none and how that creates a synchronous way to test. Writing tests using the asynch animations was driving me nuts but I just thought it was a requirement. All of this work makes maintenance much better. You are also totally right about getting the tests into source control too, this way we wont lose any testing codes. Fantastic job once again, it is an absolute pleasure to work with you. |
Moves unit tests into the repo and makes them run 8 times faster
I've been doing unit testing with jUnit in Java for the last 2 years and I've always wanted to unit test my JavaScript but I never know what library to use and how to set everything up.
The unit tests you've creates were incredibly helpful in delivering the new features, and a great example I used to start unit testing my JavaScript code at work.
But I want to be able to run the test at the press of a button and get feedback instantly (just like I do in eclipse and maven in Java).
And this is exactly what this pull request does.
I moved the unit tests out of the fiddle and into the repo.
This allows us to collaborate, keep track of changes and avoid what happened with the HTML 5 month input tests.
The new fiddle focuses on showcasing the plugins features and allowing the potential user to tryout it's features by playing around with the examples on the JavaScript panel.
So how does unit testing work now:
When you clone (or pull the changes into your working directory) you run
npm installwhich will download grunt-contrib-qunit which runs QUnit unit tests in a headless PhantomJS instance.So from now on running the
gruntcommand will run the unit test and require them to pass before creating a minified file.Running
grunt testwill only run the unit tests, and of course you can run the tests in any modern web browser by opening test/test.html.Running
npm installwill also download and install bower which takes care of downloading the libraries required for testing and allows us to have fast offline tests without keeping a copy of jQuery UI and QUnit in the repo.So how does the demo work now:
I've made grunt produce the demo/Demo.min.js and demo/Demo.min.css which contain the digital bash masked input plugin and the Month Picker code which is referenced in the new fiddle using rawgit.com which serves raw files directly from GitHub with proper Content-Type headers.
So once you make the fiddle reference the demo files in your repo new changes you push to GitHub will be reflected within minutes.
I've also added 7 new tests and 53 asserts
I've added the Button option module with 5 tests and 44 asserts.
Ive also added a a test for the
MonthFormatoption with and another test that ensures there is only one menu open at a time.I've also included some minor bug fixes that came up during the tests.
Made the tests run 8 times faster
I've added this line at the top of
test.jswhich shortens the animations which are not neccasery for automatic testing:$.KidSysco.MonthPicker.prototype.options.Duration = 1;Good to know
You can greatly simplify and improve the performance of the unit tests by passing in
Animation: 'none'which makes opening and closing the menu synchronous.I've upgraded QUnit to 1.19.1 and the new tests are written for compliance with QUnit 2.
Learning all this new stuff was an amazing experience and I hope you will like the new change.