Skip to main content
Join the official 2020 Python Developers SurveyStart the survey!

Fast functional JavaScript testing with Zombie.js

Project description

Zombie.js is a fast headless browser with all the JavaScript support Node.js provides. This package provides a function decorator, which allows Python doctest-style functional JavaScript testing using Python-like CoffeeScript.

Disclaimer: This is mostly an experiment. This wouldn’t ever replace your existing Selenium-stack, because Zombie.js, even when it works, is just an another browser with its own quirks.


  • a UNIX like environment
  • Node.js must be installed
  • npm must be installed
  • coffee-script, zombie and async packages must be installed using npm
  • coffee-executable must be found on the path

The requirements should be filled, when you can run the following command on a console without it printing anything (returning any errors):

$ echo "require 'zombie'; require 'async'"|coffee -s

Example of use (with

Start with defining a functional testing fixture with ZServer (that will run your Plone on localhost:55001 by default):

from import PLONE_FIXTURE
from import FunctionalTesting

from plone.testing import z2

FUNCTIONAL_TESTING = FunctionalTesting(
    bases=(PLONE_FIXTURE, z2.ZSERVER_FIXTURE), name="PloneFixture:ZServer")

Then write your functional JavaScript test as a doctest for your testmethod using CoffeeScript instead of Python. Define the context (URL) of your test by using the decorator (@browser) from collective.zombiedoctesting as shown below. You may use all the JavaScript that’s provided by your context and the global browser that represents Zombie.js’ browser:

import unittest

from import TEST_USER_NAME

from collective.zombiedoctesting import browser

constants = {

class LoginOverlayTest(unittest.TestCase):


    @browser("http://localhost:55001/plone/", mapping=constants)
    def test_login(self):
        Let's start by looking up the login link using the jQuery available
        on our site:

        >>> console.log $("#personaltools-login").text()
        Log in

        Clicking that link should not redirect us anywhere, but give us an
        AJAX overlay with a login form.

        >>> $("#personaltools-login").click()
        >>> console.log window.location.href
        ... console.log $(".pb-ajax #login-form").text()
        Login Name

        Let's store that form as global (to be available between different
        doctest examples) and fill it...

        >>> global.form = $(".pb-ajax #login-form")
        ... form.find("#__ac_name").val("%(TEST_USER_NAME)s")
        ... form.find("#__ac_password").val("%(TEST_USER_PASSWORD)s")
        ... console.log form.find("#__ac_name").val()
        ... console.log form.find("#__ac_password").val()

        ... and click the button to log in.

        >>> form.find("input[type='submit']").click()
        >>> console.log window.location.href
        ... console.log browser.text(".documentFirstHeading")
        You are now logged in

        Uh oh, we were properly logged in, but we were redirected also, so
        zombie is not a perfect browser yet.

        Also, notice, that we couldn't use jQuery in testing the document
        first heading (we used zombie's custom browser API), because the
        context after the click is an AJAX-response without jQuery or any
        other javascript.

Note that every parsed doctest-example (a line starting with >>>) is executed separately, but you may use Node.js’ global to make variables available between doctest-examples.

If you’d like to see the complete JavaScript generated to be run with zombie, you may add debug=True into @browser-decorator call.


1.1.0 – 2011-10-30

  • First (hopefully) non-broken release.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for collective.zombiedoctesting, version 1.1.0
Filename, size File type Python version Upload date Hashes
Filename, size (17.0 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page