cd js-test-tool python setup.py install
- Create a file describing the test suite.
js-test-tool init js_test.yml
This will create a YAML file (js_test.yml) that looks like:
- All paths are specified relative to the location of the YAML file.
- Directory paths are searched recursively.
- Paths cannot contain up-level references. For example, path/to/dir is okay, but ../path/to/dir is not. If you need to access files in directories above the test suite directory, use symbolic links.
- Run the test suite.
js-test-tool run js_test.yml --use-firefox
This will output a report to the console showing which tests passed or failed.
js-test-tool has a special mode for writing and debugging tests:
js-test-tool dev js_test.yml
This will start js-test-tool in dev mode:
- Tests will run in your default browser.
- The tool will keep running until you terminate it with Ctrl-C.
- Test results are displayed directly in the browser.
If tests take too long to run, the test runner will time out. The default timeout is 5 minutes, but you can override this:
js-test-tool run js_test.yml --use-chrome --timeout-sec 10
The above command sets the timeout to 10 seconds.
- Download and unzip JSCover
- Set the environment variable JSCOVER_JAR:
- Run js-test-tool with coverage:
js-test-tool run js_test.yml --use-phantomjs --coverage-xml=js_coverage.xml --coverage-html=js_coverage.html
This will create coverage reports in two formats:
- Cobertura XML
js-test-tool can generate XUnit-style XML reports for consumption by a CI system such as Jenkins.
js-test-tool run js_test.yml --use-firefox --xunit-report report.xml
will generate a report called report.xml.
Using command-line options, you can run the tests in multiple browsers:
js-test-tool run js_test.yml --use-chrome --use-phantomjs
will run the tests in both Chrome and PhantomJS if the browsers are installed.
The tool currently supports these browsers:
Coverage information is combined across browsers: a line is considered covered if it is executed under any browser.
Multiple Test Suites
You can run test suites sequentially:
js-test-tool run test_1.yml test_2.yml --use-firefox
If collecting coverage, then the coverage report will contain information for all files included in each test suite.
The code in this repository is licensed under version 3 of the AGPL unless otherwise noted.
Please see LICENSE.txt for details.
How to Contribute
Contributions are very welcome. The easiest way is to fork this repo, and then make a pull request from your fork. The first time you make a pull request, you may be asked to sign a Contributor Agreement.
Reporting Security Issues
Please do not report security issues in public. Please email email@example.com
Mailing List and IRC Channel
You can discuss this code on the edx-code Google Group or in the edx-code IRC channel on Freenode.