source: pyenvjasmine/README.rst@ 4:2e2373750a9e

Last change on this file since 4:2e2373750a9e was 3:a681a8b3bda3, checked in by Borja Lopez <borja@…>, 10 years ago

Added .hgignore file

File size: 1.8 KB
RevLine 
[0]1Python envjasmine wrapper
2=========================
3
4This is a thin python wrapper around the envjasmine_ JavaScript
5testing framework.
6
7.. _envjasmine : https://github.com/trevmex/EnvJasmine
8
9
10Running the tests of this python module:
11----------------------------------------
12
13To run the tests on this code here (as opposed to *your* JavaScript
14code you want to test), install this into a virtualenv, install
15nose and maybe coverage in that virtualenv and then run::
16
17 nosetests --cover-package=pyenvjasmine --cover-erase \
18 --with-coverage --with-doctest $*
19
20
21Run your own tests
22------------------
23
24The easiest way is to put your "specs" (JavaScript tests) into
25some directory in your code, then in your python tests, add a new
26TestCase with just one test that runs all your JavaScript tests.
27
28The simplest solution is to set capture_output to False, so you see
29the output from the js tests on the console. Something like this::
30
31 import unittest
32 from pyenvjasmine.runner import TestRunner
33
34 class JavaScriptTests(unittest.TestCase):
35 def test_my_javascript(self):
36 runner = TestRunner(
37 testdir='/path/to/my/testdir',
38 configfile='relative/path/to/configfile')
39 runner.run(capture_output=False)
40
41
42If you want a more integrated
43test control, you could set capture_output to True, then parse the test
44output that is returned from the run() method, with something like this::
45
46 def test_my_javascript_no_output(self):
47 runner = TestRunner(
48 testdir='/path/to/my/testdir',
49 configfile='relative/path/to/configfile')
50 res = runner.run(capture_output=True)
51 lines = res.splitlines()
52 self.assertTrue('Failed: 0' in lines)
53
Note: See TracBrowser for help on using the repository browser.