Re: [openstack-dev] [horizon] Packaging Sinon.JS as xstatic

2014-10-14 Thread Timur Sufiev
Adding yesterday discussion of JS libs for unit-testing in
#openstack-horizon: http://paste2.org/B9xN1yI4

On Mon, Oct 13, 2014 at 5:01 PM, Timur Sufiev tsuf...@mirantis.com wrote:

 Hello folks!

 Discussing the proposed Sinon.js dependency to Horizon on the last meeting
 has brought quite an expected question: why should we add it when there is
 already such wonderful testing framework as Jasmine? And if you need some
 testing feature present in Jasmine, why not rewrite your QUnit test in
 Jasmine? I was not ready to answer the question at that moment so I took a
 pause to learn more about Jasmine capabilities compared to Sinon.JS.

 First of all, I googled to see if someone did this investigation before.
 Unfortunately, I haven't found much: judging from the links [1], [2] both
 Jasmine and Sinon.JS provide the same functionality, while Sinon.JS is a
 bit more flexible and could be more convenient in some cases (I guess those
 cases are specific to the project being tested).

 Then I had studied Jasmine/Sinon.JS docs and repos myself and have found
 that:
 * both project repos have lots of contributors and fresh commits
 * indeed, they provide roughly the same functionality: matchers/testing
 spies/stubs/mocks/faking timers/AJAX mocking, but
 * to use AJAX mocking in Jasmine, you need to use a separate library [5],
 which I guess means another xstatic dependency besides xstatic-jasmine if
 you want to mock AJAX calls via Jasmine
 * Sinon.JS has a much more comprehensive documentation [6] than Jasmine
 [3], [4]

 So, while Horizon doesn't have too many QUnit tests meaning that they
 could be rewritten in Jasmine in a relatively short time, it seems that in
 order to mock AJAX requests (the reason I looked to the Sinon.JS) in
 Jasmine another xstatic dependency should be added (Radomir Dopieralski
 could correct me here if I'm wrong). Also, I've found quite an interesting
 feature in Sinon.JS's AJAX mocks: it is possible to mock only a filtered
 set of server calls and let others pass through [7] - didn't find such
 feature in Jasmine ajax.js docs. On the other hand, reducing all JS
 unit-tests to one framework is good thing also, and given that Jasmine is
 officially used for Angular.js testing, I'd rather see Jasmine as the 'only
 Horizon JS unit-testing framework' than the QUnit. But then, again: want to
 have AJAX mocks = add 'jasmine-ajax' dependency to the already existing
 'jasmine' (why not add Sinon.JS then?).

 Summarizing all the things I've written so far, I would:
 * replace QUnit with Jasmine (=remove QUnit dependency)
 * add Sinon.JS just to have its AJAX-mocking features.

 [1] http://stackoverflow.com/questions/15002541/does-jasmine-need-sinon-js
 [2]
 http://stackoverflow.com/questions/12216053/whats-the-advantage-of-using-sinon-js-over-jasmines-built-in-spys
 [3] http://jasmine.github.io/1.3/introduction.html
 [4] http://jasmine.github.io/2.0/ajax.html
 [5] https://github.com/pivotal/jasmine-ajax
 [6] http://sinonjs.org/docs/
 [7] http://sinonjs.org/docs/#server search for 'Filtered requests'

 On Tue, Oct 7, 2014 at 1:19 PM, Timur Sufiev tsuf...@mirantis.com wrote:

 Hello all!

 Recently I've stumbled upon wonderful Sinon.JS library [1] for stubs and
 mocks in JS unit tests and found that it can be used for simplifying unit
 test I've made in [2] and speeding it up. Just before wrapping it as
 xstatic package I'd like to clarify 2 questions regarding Sinon.JS:

 * Are Horizon folks fine with adding this dependency? Right now it will
 be used just for one test, but it would be useful for anybody who wants to
 mock AJAX requests in tests or emulate timeout events being fired up
 (again, see very brief and concise examples at [1]).
 * Is it okay to include QUnit and Jasmine adapters for Sinon.JS in the
 same xstatic package? Well, personally I'd vote for including QUnit adapter
 [3] since it has very little code and allows for seamless integration of
 Sinon.JS with QUnit testing framework. If someone is interested in using
 Jasmine matchers for Sinon [4], please let me know.

 [1] http://sinonjs.org/
 [2]
 https://review.openstack.org/#/c/113855/2/horizon/static/horizon/tests/tables.js
 [3] http://sinonjs.org/qunit/
 [4] https://github.com/froots/jasmine-sinon

 --
 Timur Sufiev




 --
 Timur Sufiev




-- 
Timur Sufiev
___
OpenStack-dev mailing list
OpenStack-dev@lists.openstack.org
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev


Re: [openstack-dev] [horizon] Packaging Sinon.JS as xstatic

2014-10-13 Thread Timur Sufiev
Hello folks!

Discussing the proposed Sinon.js dependency to Horizon on the last meeting
has brought quite an expected question: why should we add it when there is
already such wonderful testing framework as Jasmine? And if you need some
testing feature present in Jasmine, why not rewrite your QUnit test in
Jasmine? I was not ready to answer the question at that moment so I took a
pause to learn more about Jasmine capabilities compared to Sinon.JS.

First of all, I googled to see if someone did this investigation before.
Unfortunately, I haven't found much: judging from the links [1], [2] both
Jasmine and Sinon.JS provide the same functionality, while Sinon.JS is a
bit more flexible and could be more convenient in some cases (I guess those
cases are specific to the project being tested).

Then I had studied Jasmine/Sinon.JS docs and repos myself and have found
that:
* both project repos have lots of contributors and fresh commits
* indeed, they provide roughly the same functionality: matchers/testing
spies/stubs/mocks/faking timers/AJAX mocking, but
* to use AJAX mocking in Jasmine, you need to use a separate library [5],
which I guess means another xstatic dependency besides xstatic-jasmine if
you want to mock AJAX calls via Jasmine
* Sinon.JS has a much more comprehensive documentation [6] than Jasmine
[3], [4]

So, while Horizon doesn't have too many QUnit tests meaning that they could
be rewritten in Jasmine in a relatively short time, it seems that in order
to mock AJAX requests (the reason I looked to the Sinon.JS) in Jasmine
another xstatic dependency should be added (Radomir Dopieralski could
correct me here if I'm wrong). Also, I've found quite an interesting
feature in Sinon.JS's AJAX mocks: it is possible to mock only a filtered
set of server calls and let others pass through [7] - didn't find such
feature in Jasmine ajax.js docs. On the other hand, reducing all JS
unit-tests to one framework is good thing also, and given that Jasmine is
officially used for Angular.js testing, I'd rather see Jasmine as the 'only
Horizon JS unit-testing framework' than the QUnit. But then, again: want to
have AJAX mocks = add 'jasmine-ajax' dependency to the already existing
'jasmine' (why not add Sinon.JS then?).

Summarizing all the things I've written so far, I would:
* replace QUnit with Jasmine (=remove QUnit dependency)
* add Sinon.JS just to have its AJAX-mocking features.

[1] http://stackoverflow.com/questions/15002541/does-jasmine-need-sinon-js
[2]
http://stackoverflow.com/questions/12216053/whats-the-advantage-of-using-sinon-js-over-jasmines-built-in-spys
[3] http://jasmine.github.io/1.3/introduction.html
[4] http://jasmine.github.io/2.0/ajax.html
[5] https://github.com/pivotal/jasmine-ajax
[6] http://sinonjs.org/docs/
[7] http://sinonjs.org/docs/#server search for 'Filtered requests'

On Tue, Oct 7, 2014 at 1:19 PM, Timur Sufiev tsuf...@mirantis.com wrote:

 Hello all!

 Recently I've stumbled upon wonderful Sinon.JS library [1] for stubs and
 mocks in JS unit tests and found that it can be used for simplifying unit
 test I've made in [2] and speeding it up. Just before wrapping it as
 xstatic package I'd like to clarify 2 questions regarding Sinon.JS:

 * Are Horizon folks fine with adding this dependency? Right now it will be
 used just for one test, but it would be useful for anybody who wants to
 mock AJAX requests in tests or emulate timeout events being fired up
 (again, see very brief and concise examples at [1]).
 * Is it okay to include QUnit and Jasmine adapters for Sinon.JS in the
 same xstatic package? Well, personally I'd vote for including QUnit adapter
 [3] since it has very little code and allows for seamless integration of
 Sinon.JS with QUnit testing framework. If someone is interested in using
 Jasmine matchers for Sinon [4], please let me know.

 [1] http://sinonjs.org/
 [2]
 https://review.openstack.org/#/c/113855/2/horizon/static/horizon/tests/tables.js
 [3] http://sinonjs.org/qunit/
 [4] https://github.com/froots/jasmine-sinon

 --
 Timur Sufiev




-- 
Timur Sufiev
___
OpenStack-dev mailing list
OpenStack-dev@lists.openstack.org
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev


[openstack-dev] [horizon] Packaging Sinon.JS as xstatic

2014-10-07 Thread Timur Sufiev
Hello all!

Recently I've stumbled upon wonderful Sinon.JS library [1] for stubs and
mocks in JS unit tests and found that it can be used for simplifying unit
test I've made in [2] and speeding it up. Just before wrapping it as
xstatic package I'd like to clarify 2 questions regarding Sinon.JS:

* Are Horizon folks fine with adding this dependency? Right now it will be
used just for one test, but it would be useful for anybody who wants to
mock AJAX requests in tests or emulate timeout events being fired up
(again, see very brief and concise examples at [1]).
* Is it okay to include QUnit and Jasmine adapters for Sinon.JS in the same
xstatic package? Well, personally I'd vote for including QUnit adapter [3]
since it has very little code and allows for seamless integration of
Sinon.JS with QUnit testing framework. If someone is interested in using
Jasmine matchers for Sinon [4], please let me know.

[1] http://sinonjs.org/
[2]
https://review.openstack.org/#/c/113855/2/horizon/static/horizon/tests/tables.js
[3] http://sinonjs.org/qunit/
[4] https://github.com/froots/jasmine-sinon

-- 
Timur Sufiev
___
OpenStack-dev mailing list
OpenStack-dev@lists.openstack.org
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev