Changes between Initial Version and Version 1 of pyenvjasmine


Ignore:
Timestamp:
Sep 4, 2019, 4:15:49 PM (2 years ago)
Author:
borja
Comment:

Added a wiki page for pyenvjasmine

Legend:

Unmodified
Added
Removed
Modified
  • pyenvjasmine

    v1 v1  
     1{{{
     2#!rst
     3
     4Python envjasmine wrapper
     5=========================
     6
     7This is a thin python wrapper around the envjasmine_ JavaScript
     8testing framework.
     9
     10
     11.. contents::
     12
     13
     14Installation
     15------------
     16
     17You can install pyenvjasmine using pip_::
     18
     19  pip install pyenvjasmine
     20
     21Or you can grab the latest sources and install it from there::
     22
     23  python setup.py install
     24
     25Also, you can use it directly from the sources directory, in *development mode*
     26(useful if you want to contribute to the project)::
     27
     28  pip install -e .
     29
     30.. note::
     31
     32   More about the *development mode* here:
     33
     34   https://packaging.python.org/en/latest/distributing.html#working-in-development-mode
     35
     36.. warning::
     37
     38   Starting with version **0.3.0**, pyenvjasmine has support to run tests with
     39   different browsers/engines. The headless browser rhino is included with
     40   pyenvjasmine, but in order to use the other engines, you have to install the
     41   needed browser(s).
     42
     43   Right now, only phantomjs_ is supported, so ensure you have it installed if
     44   you want to use that browser/engine to run tests on. **Required if you want
     45   to run tests on jasmine 3.x** (also required to run pyenvjasmine's own
     46   tests).
     47
     48
     49Running pyenvjasmine tests
     50--------------------------
     51
     52To run the tests on this code here (as opposed to *your* JavaScript code you
     53want to test), install pyenvjasmine (and phantomjs) and then run::
     54
     55  py.test
     56
     57
     58Run your own tests
     59------------------
     60
     61The easiest way is to put your "specs" (JavaScript tests) into some directory
     62in your code, then in your python tests, add a new TestCase with just one test
     63that runs all your JavaScript tests.
     64
     65The simplest solution is to set capture_output to False, so you see the output
     66from the js tests on the console. Something like this::
     67
     68    import pytest
     69    from pyenvjasmine.runner import Runner
     70
     71    class TestJavaScript(object):
     72        def test_my_javascript(self):
     73            runner = Runner(
     74                testdir='/path/to/my/testdir',
     75                configfile='relative/path/to/configfile',
     76                testing_environment='phantomjs')
     77            success, stdout = runner.run()
     78            # assert on success, will be true if tests passed, False if any
     79            # test failed
     80            assert success, "One or more javascript tests have failed"
     81            # you can inspect stdout if you want to get more info, but it
     82            # will be printed to the console stdout anyway
     83            assert b'Total: 120' in stdout
     84
     85In this example, the *phantomjs* browse/engine is used, replace that with
     86*rhino* to run tests on rhino + jasmine 1.x.
     87
     88.. note::
     89
     90   *phantomjs* is the preferred browser/engine, so it is what pyenvjasmine
     91   will use as a default if you don't set *testing_environment* when creating
     92   a new *Runner* instance.
     93
     94.. _envjasmine : https://github.com/trevmex/EnvJasmine
     95.. _pip: http://www.pip-installer.org/en/latest/index.html
     96.. _easy_install: http://peak.telecommunity.com/DevCenter/EasyInstall
     97.. _phantomjs: http://phantomjs.org
     98
     99
     100}}}