Package: js_test_tool
Run JavaScript test suites and collect coverage information.Installationcdjs-test-toolpythonsetup.pyinstallGetting StartedCreate a file describing the test suite.js-test-toolinitjs_test.ymlThis will create a YAML file (js_test.yml) that looks like:---# Name of the test suite, used to construct# the URL from which pages are served.## For example, if the suite name is "test_suite",# then:##   * /suite/test_suite#     serves the test suite runner page#   * /suite/test_suite/include/*#     serves dependencies (src, spec, lib, and fixtures)## Test suite names must be URL-encodable and unique# among suite descriptions passed to js-test-tooltest_suite_name:test_suite# Currently, the only supported test runner is Jasmine# See http://pivotal.github.io/jasmine/# for the Jasmine documentation.test_runner:jasmine# Path prepended to source files in the coverage report (optional)# For example, if the source path# is "src/source.js" (relative to this YAML file)# and the prepend path is "base/dir"# then the coverage report will show# "base/dir/src/source.js"prepend_path:base/path# Paths to library JavaScript files (optional)lib_paths:-path/to/lib# Paths to source JavaScript filessrc_paths:-path/to/src# Paths to spec (test) JavaScript filesspec_paths:-path/to/spec# Paths to fixture files (optional)# The fixture path will be set automatically when using jasmine-jquery.# (https://github.com/velesin/jasmine-jquery)## You can then access fixtures using paths relative to# the test suite description:##   loadFixtures('path/to/fixture/fixture.html');#fixture_paths:-path/to/fixture# Regular expressions used to exclude *.js files from# appearing in the test runner page.# Some test runners (like the jasmine runner) include files by default,# which means that they are loaded using a <script> tag in the test# runner page. When loading many files, this can be slow, so# exclude any files you don't need.# Note that not all runners behave the same way: for example, the# jasmine_requirejs runner does not include files using <script> tags# by default, and so will ignore this directive.exclude_from_page:-path/to/lib/exclude/.*# Regular expression used to guarantee that a *.js file# is included in the test runner page.# If a file name matches both `exclude_from_page` and# `include_in_page`, the file WILL be included.# You can use this to exclude all files in a directory,# but make an exception for particular files.include_in_page:-path/to/lib/exclude/exception_.*\.jsAll paths are specified relative
to the location of the YAML file.Directory paths are searched recursively.JavaScript files are loaded in the specified order.Paths cannot contain up-level references. For example,path/to/diris okay,
but../path/to/diris not.
If you need to access files in directories above the test suite directory,
use symbolic links.Run the test suite.js-test-toolrunjs_test.yml--use-firefoxThis will output a report to the console showing which tests passed or failed.Dev Modejs-test-toolhas a special mode for writing and debugging tests:js-test-tooldevjs_test.ymlThis will startjs-test-toolindev mode:Tests will run in your default browser.The tool will keep running until you terminate it withCtrl-C.Test results are displayed directly in the browser.TimeoutsIf 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-toolrunjs_test.yml--use-chrome--timeout-sec10The above command sets the timeout to 10 seconds.CoverageTo collect JavaScript coverage:Download and unzipJSCoverSet the environment variableJSCOVER_JAR:exportJSCOVER_JAR=~/jscover/target/dist/JSCover-all.jarRunjs-test-toolwith coverage:js-test-toolrunjs_test.yml--use-phantomjs--coverage-xml=js_coverage.xml--coverage-html=js_coverage.htmlThis will create coverage reports in two formats:Cobertura XMLHTMLXUnit Reportsjs-test-toolcan generate XUnit-style XML reports for consumption
by a CI system such as Jenkins.js-test-toolrunjs_test.yml--use-firefox--xunit-reportreport.xmlwill generate a report calledreport.xml.Multiple BrowsersUsing command-line options, you can run the tests in
multiple browsers:js-test-toolrunjs_test.yml--use-chrome--use-phantomjswill run the tests in both Chrome and PhantomJS if the
browsers are installed.The tool currently supports these browsers:ChromePhantomJSFirefoxCoverage information is combined across browsers: a line is
considered covered if it is executed underanybrowser.Multiple Test SuitesYou can run test suites sequentially:js-test-toolruntest_1.ymltest_2.yml--use-firefoxIf collecting coverage, then the coverage report
will contain information for all files included
in each test suite.LicenseThe code in this repository is licensed under version 3 of the AGPL unless
otherwise noted.Please seeLICENSE.txtfor details.How to ContributeContributions 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 IssuesPlease do not report security issues in public. Please emailsecurity@edx.orgMailing List and IRC ChannelYou can discuss this code on theedx-code Google Groupor in theedx-codeIRC channel on Freenode.