Skip to main content

Djasmine

Build Status Coverage Status

This app integrates Jasmine JavaScript tests with the Django test framework in a simple but effective DRY way. Using it you can easily write and run tests that integrates your frontend and backend in a manner that is much easier to maintain than selenium tests interacting with full web pages.

You can either run individual jasmine spec files and check the result from within your Django test suit or open an url from your devserver and run all specs at once, checking the result on the webpage.

Getting started

  1. Add 'djasmine' to your INSTALLED_APPS:

    INSTALLED_APPS = [
        ...
        'djasmine',
    ]
  2. Include the djasmine URLconf in your project urls.py like this:

    url(r'^djasmine/', include('djasmine.urls')),
  3. Add the following to your project settings:

    import jasmine_core
    
    JASMINE_SPEC_ROOT = BASE_DIR + '/path/to/spec/files'
    
    STATICFILES_DIRS = [
        jasmine_core.__path__[0],
        JASMINE_SPEC_ROOT,
    ]
  4. Now you need to get your site’s JavasSript files included by the Djasmine runner view. You probably already have them written out in your 'base.html' template or similar. In order to keep DRY you don’t want to provide this list again in some test setup file, and with Djasmine you don’t have to. Instead break out the list of javascript tags into a special top-level template called 'javascripts.html' and include this in your 'base.html' (or similar). This template will also be picked up by the spec runner code. If you are using e g compressor preprocessing tags the template include approach allows you to use these also for the test running code.

For more specialized needs you can provide your own 'djasmine/specrunner.html' template.

Running Jasmine specs from Django tests

Create your Django tests by using djasmine.testcase.JasmineRunnerTestCase as base class for your test cases. There is one required class property, webdriver, that should specify the Selenium WebDriver class you wish to use for the test, e g selenium.webdriver.firefox.webdriver.WebDriver.

Run and check result of a Jasmine spec file with the assertSpecPasses method, which takes one argument: the name of your spec file.

Example:

from djasmine.testcase import JasmineRunnerTestCase
from selenium.webdriver.firefox.webdriver import WebDriver


class MyIntegrationTest(JasmineRunnerTestCase):
    webdriver = WebDriver

    def test_all_works_nicely(self):
        self.assertSpecPasses('my_tests.spec.js')  # Runs everything in this spec file and checks result

        ...
        (other checks of backend state possible here)
        ...

Metadata

Release files for djasmine 0.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for djasmine 0.2.3
File Size Uploaded Provenance Actions
djasmine-0.2.3.tar.gz 4.8 kB Without provenance Details for djasmine-0.2.3.tar.gz

Release files / djasmine-0.2.3.tar.gz

Download URL djasmine-0.2.3.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
900e5d2b6ad6f3b769648089d8cc1c8c04f5dedb951e5bc0614f3853deab130b
BLAKE2b-256 checksum
How to use checksums
d9ebe1ae458eadcc986e0e48f0d83d3d35168babe0279ebbebbdf06634967564
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for djasmine 0.2.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.3 This release

1 release file No provenance

0.1

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page