LinkedInAttic / venus.js

where bugs go to die
http://venusjs.readthedocs.io/en/latest/
Other
298 stars 44 forks source link

Dependencies

Overview

Venus is a testing tool for JavaScript (JS), which simplifies running unit tests. When you are developing a browser-based project in JS, you'll want to create unit tests and run them frequently. Typically, you'll write a unit test using some library, such as Mocha or Jasmine. These libraries let you define testcases (or "specs" if you are following a BDD style), and provide APIs for writing assertions.

To run one of your tests in the browser, you need to have a test harness page. The harness page is simply an HTML document which includes several JS files:

You may also include some DOM elements for your test to interact with, or for the testing library to display results.

For example, your test harness might look something like this:

  <!DOCTYPE html>
  <html>
  <head>
    <title>Test for Foo</title>
    <script type="text/javascript" src="https://github.com/LinkedInAttic/venus.js/raw/master/lib/jquery.js"></script>
    <script type="text/javascript" src="https://github.com/LinkedInAttic/venus.js/raw/master/lib/testing_library.js"></script>
    <script type="text/javascript" src="https://github.com/LinkedInAttic/venus.js/raw/master/foo.js"></script>
    <script type="text/javascript" src="https://github.com/LinkedInAttic/venus.js/raw/master/specs/foo.spec.js"></script>
    <script type="text/javascript">
        testLibrary.run();
    </script>
  </head>
  <body>
    <div id="results"></div>
  </body>
  </html>

then to run the test, you simply load this page in any web browser. This works, but it presents some problems:

  1. Generating this test harness page is often a manual process
  2. Running the test is a manual process of launching a browser, and visually inspecting the page for results
  3. There is often no easy way to integrate running tests from an IDE, since there is no command line output from running the test

Venus to the rescue

Venus strives to solve these problems without re-inventing the wheel. Rather than create an entirely new testing library, we set out to create a tool to make it easier for you to work with an existing library. Here are the main benefits of Venus:

Annotations

In your test file, the following annotations are supported:

Get started

Visit the project page at http://venusjs.readthedocs.io/en/latest/ for more information.