source: pyenvjasmine/README.rst@ 28:4b7c393bb98b

Last change on this file since 28:4b7c393bb98b was 26:14c16e5cbe03, checked in by Borja Lopez <borja@…>, 7 years ago

Replaced nose with py.test and adapted all existing tests

File size: 2.0 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
18Or you can grab the latest sources and install it from there::
19
20 python setup.py install
21
22Also, you can use it directly from the sources directory, in *development mode*
23(useful if you want to contribute to the project)::
24
[21]25 pip install -e .
[8]26
27.. note::
28
29 More about the *development mode* here:
30
31 https://packaging.python.org/en/latest/distributing.html#working-in-development-mode
[0]32
33
[11]34Running pyenvjasmine tests
35--------------------------
[0]36
[11]37To run the tests on this code here (as opposed to *your* JavaScript code you
38want to test), install pyenvjasmine and then run::
[0]39
[26]40 py.test
[8]41
[0]42
43Run your own tests
44------------------
45
[11]46The easiest way is to put your "specs" (JavaScript tests) into some directory
47in your code, then in your python tests, add a new TestCase with just one test
48that runs all your JavaScript tests.
[0]49
[11]50The simplest solution is to set capture_output to False, so you see the output
51from the js tests on the console. Something like this::
[0]52
[26]53 import pytest
[24]54 from pyenvjasmine.runner import Runner
[0]55
[26]56 class TestJavaScript(object):
[0]57 def test_my_javascript(self):
[24]58 runner = Runner(
59 testdir='/path/to/my/testdir',
60 configfile='relative/path/to/configfile')
[26]61 success, stdout = runner.run()
62 # assert on success, will be true if tests passed, False if any
63 # test failed
64 assert success
65 # you can inspect stdout if you want to get more info, but it
66 # will be printed to the console stdout anyway
67 assert b'Total: 120' in stdout
[0]68
[8]69
70.. _envjasmine : https://github.com/trevmex/EnvJasmine
71.. _pip: http://www.pip-installer.org/en/latest/index.html
72.. _easy_install: http://peak.telecommunity.com/DevCenter/EasyInstall
Note: See TracBrowser for help on using the repository browser.