Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Unit testing Macro JavaScripts

Robert Krause
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 10, 2014

I am developing plugins that use JavaScript, and I want to write Unit Tests for them using Jasmine. Since they use a lot of functions from AJS and other JavaScript supplied by Atlassian I would like to know if there are any best practises regarding that topic. Is there easy access to the required JS files or is it neccessary to mock every AJS (etc. ) function I use in my JavaScript?

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Robert Krause
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 19, 2014

So I figured out the best way to do this is to run karma with maven as atlassian suggests. However this is not always what you want to do (because Maven) so I started to work on a mock for AJS, that you can use if you do not want to include the complete AJS. Feel free to contibute.

0 votes
Felix Grund (Scandio)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 11, 2014

We had the same question regarding our company-internal Confluence JS libraries we wanted to unit test. We thought about two alternatives: (1) include the whole AJS stuff as testing dependencies; (2) mock only the AJS contents we use in our libs. In the end we went with approach (2), since we didn't want to maintain somehing like 2 MB of AJS code that needs updates regularly. I don't know if there are further alternatives though.

Robert Krause
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 19, 2014

I figured out Atlassian provides a way to automate this with maven. Works pretty good for me.

https://bitbucket.org/atlassian/confluence-karma-test-runner-support

TAGS
AUG Leaders

Atlassian Community Events