NoseJS is a Nose plugin to run JavaScript tests using Rhino in a Java subprocess.
Usage:
Here is the most basic way to invoke NoseJS (assumes you've downloaded Rhino into ~/src)
$ nosetests --with-javascript --rhino-jar ~/src/rhino1_7R1/js.jar
This command would look for any files along Nose's path ending in .js that match Nose's current test pattern, collect them all, then execute them using Rhino in a single Java subprocess at the end of all other tests. By default, files looking like test*.js will be collected and run.
The idea behind NoseJS is that you might have a Python web application that relies on JavaScript for some of its functionality and you want to run both Python and JavaScript tests with one command, nosetests. You can put these JavaScript tests wherever you want in your project.
Here is a more realistic example that shows how the Fudge project is tested simultaneously for Python and JavaScript functionality. Its project layout looks roughly like this:
|-- fudge
| |-- __init__.py
| |-- patcher.py
| |-- tests
| | |-- __init__.py
| | |-- test_fudge.py
| | |-- test_patcher.py
|-- javascript
| |-- fudge
| | |-- fudge.js
| | |-- tests
| | | |-- test_fudge.html
| | | `-- test_fudge.js
`-- setup.py
Both Python and JavaScript tests can be run with this command:
$ nosetests --with-javascript
--rhino-jar ~/src/rhino1_7R1/js.jar
--with-dom
--js-test-dir javascript/fudge/tests/
......................................................
----------------------------------------------------------------------
Test Fake
can find objects
can create objects
expected call not called
call intercepted
returns value
returns fake
Test ExpectedCall
ExpectedCall properties
call is logged
Test fudge.registry
expected call not called
start resets calls
stop resets calls
global stop
global clear expectations
Loaded 6 JavaScript files
OK
----------------------------------------------------------------------
Ran 54 tests in 0.392s
OK
The dots are the Python tests that were run and the output below that is what Fudge's JavaScript test files printed out.
Product's homepage
Requirements:
· Python
What's New in This Release: [ read full changelog ]
· Multiple paths for the --javascript-dir option can now be specified on multiple lines in setup.cfg