source: pyenvjasmine/README.rst

0.3.1
Last change on this file was 47:de07b0e7bd7a, checked in by Borja Lopez <borja@…>, 14 months ago

Updated README file(s) to show where and how you can get the project sources

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