How can I run jQuery jQuery Jenskins tests?

I wrote some casperjs tests to test my Django application. If the Django application is running (for example, on port 8000), casperjs can be launched as a separate process and access my running Django application.

My other tests are written using the Django (web) testing platform, which installs a test database using fixtures and starts with ./manage.py test . With the Django website, you do not need to run a separate Django web server (requests and routing URLs are proxied / simulated).

Is there a way to run casperjs tests from a Django website? Without starting another web server and having another test database?

I have seen ghost.py exist, but have not tried it yet.

+6
source share
2 answers

I managed to find a solution. After migrating to Django 1.4, I can use LiveServerTestCase and fork casperjs in the subprocess:

 from django.test.testcases import LiveServerTestCase import os, subprocess from subprocess import Popen, PIPE, STDOUT class CasperTest(LiveServerTestCase): fixtures = ['test_initial_data', ] def test_my_testcase(self): p = Popen(['casperjs %s/caspertest.js' % os.path.dirname(__file__)], shell=True, stdout=PIPE, stderr=STDOUT, close_fds=True) output = p.stdout.read() print output 
+3
source

You should take a look at django-casper . I started using it a few days ago, and it's just awesome!

+1
source

All Articles