jakeharding / django-jasmine

Package to integrate Jasmine with Django
Other
78 stars 27 forks source link

Integration of jasmine-jquery into django-jasmine #22

Open DanielSwain opened 7 years ago

DanielSwain commented 7 years ago

The following statement in the ReadMe is not clear as far as local testing: django-jasmine also integrates the jasmine-jquery plugin, that provides a set of custom matchers for jQuery framework and an API for handling HTML fixtures in your specs.

Most of the ReadMe seems to be talking about local display of test results (i.e. when the results are rendered to index.html), so I think that the instructions should address things from this angle.

ALSO, I tried using jasmine-jquery commands in my tests, and they failed, of course, because jasmine-jquery wasn't on my local system. I placed it in my "static/js" folder and placed the following script tag as the last of the {# core files #} in base.html: <script type="text/javascript" src="{% static 'jasmine-jquery.js' %}"></script>. This caused an error because I have to reference jQuery in files.json. When I moved the script tag for jasmine-jquery to AFTER the {# source files #}, everything was then found OK.

I would suggest the following (where DJ_ stands for django-jasmine):

  1. In settings.py: DJ_JQUERY_URL and then use this variable in base.html to automatically include jQuery (ideally this would be parsed so that it could be either a url within the folder structure or a CDN url if not using jQuery locally). If jasmine-jquery is being included automatically, then it seems like jQuery should be also.
  2. Explain that jasmine-jquery has to be downloaded separately if testing is being done locally.
  3. in settings.py: DJ_JASMINE_JQUERY_URL -- this is the location on the local system to which jasmine-jquery has been copied.
jakeharding commented 7 years ago

These a good suggestions, and improving the jasmine-jquery integration is on the TODO list in the readme. I hesitate to add DJ_JQUERY_URL and DJ_JASMINE_JQUERY_URL to the settings because jQuery and jasmine-jquery are static libraries not every project depends on. If a project uses these libraries they can include them with their static files.

Better explanation around how to use jasmine-jquery is a great idea, and we can leave this issue open until it is included in the readme. Thanks. 😁