Giter Site home page Giter Site logo

prova's Introduction

prova

Node & Browser Test runner based on Tape and Browserify.

Screencasts: node.gif, browser.gif, both.gif, headless browser

Features and screenshots:

Install

$ npm install -g prova

Usage

Example test:

var test = require('prova')

test('timing test', function (t) {
  t.plan(2)

  t.equal(typeof Date.now, 'function')
  var start = Date.now()

  setTimeout(function () {
    t.equal(Date.now() - start, 100)
  }, 100)
})

In Node, it will output:

$ node test.js
Passed 1 test.

Or, in case it fails:

In Browser

To run the tests in a web browser, just pass -b parameter:

$ node test.js -b
Visit localhost:7559 with a browser to start running the tests.

Then visit localhost:7559 in your web browser:

In case it fails, it'll show:

The web app uses watchify to monitor file changes. So, you won't have to reload the page when you modify a source code.

Prova runs the tests inside of an iframe. In case you test some UI stuff, you can open the iframe by clicking the < button on the right:

Multiple Tests

Prova comes with a command-line script when you install it globally;

$ npm install -g prova

And it allows you running multiple tests on both Node and browser;

$ prova test/foo.js test/bar.js
$ prova test/**/*.js -b

Launching Browsers and Headless Testing

List the detected browsers;

$ prova -l
Available Browsers: safari v7.0.2, chrome v34.0.1847.116, phantom v1.9.7

And launch after publishing the tests:

$ prova -b -l safari

If your system has Xvfb, you can pass -e parameter to open the browser headlessly:

$ prova -b -l chrome -e

Or you can just run the tests on PhantomJS:

$ prova -b -l phantom

If you get no matches for errors and you think that your system has that browser, try removing browser-launcher's config:

$ rm /Users/azer/.config/browser-launcher/config.json

Command-line

    USAGE

        prova [filenames] [options]

    OPTIONS

        -g     --grep       Run tests matching with given pattern

        -b     --browser    Publishes the tests on 0.0.0.0:7559
        -o     --port       Publish the tests on given port number.
        -d     --hostname   Publih the tests on given hostname.
        -l     --launch     List available browsers to launch or launch specified browser.
        -e     --headless   Launch the browser headlessly. (Requires xvfb)
        -r     --proxy      Launch the browser with specified proxy configuration.
        -q     --quit       Shut down the browser server once all the tests are done.

        -v     --version    Show version and exit
        -h     --help       Show help and exit

    EXAMPLES

        1. Run the tests on NodeJS.

           $ node test.js
           $ node test
           $ prova test/index.js
           $ prova

           All the above example commands will work same way. Prova assumes the filename of your test is either `test.js` or `test/index.js`

       2. Publish the tests on localhost:7559, so you can run the tests on a web browser.

          $ node test.js -b
          $ prova test -b
          $ prova -b

       3. Publish the tests on given host and port.

          $ node test.js -o 8080 -d foobar.net
          $ prova test.js -p 8080 -d foobar.net

       4. Publish the tests and launch a browser to automatically run the tests.

          $ node test.js -b -l chrome
          $ prova test.js -b -l chrome

       5. List the browsers that can be launched automatically.

          $ prova -l
          $ node test.js -l

       6. Run the tests with PhantomJS.

          $ node test.js -b -l phantom
          $ prova test.js -b -l phantom

       7. Run only specified tests with PhantomJS.

          $ node test.js -b -l phantom -g pattern
          $ prova test.js -b -l phantom -g pattern

       8. Launch Chrome headlessly using xvfb:

          $ node test -b -l chrome -e
          $ prova test -b -l chrome -e

prova's People

Contributors

unc0 avatar

Watchers

Joey Baker avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.