• Stars
    star
    334
  • Rank 121,518 (Top 3 %)
  • Language
    JavaScript
  • License
    Other
  • Created about 10 years ago
  • Updated almost 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Test runner based on Tape and Browserify

prova

Node & Browser Test runner based on Tape and Browserify.

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

Slides: slides.com/azer/prova

Features and screenshots:

Install

$ npm install -g azer/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

Browserify Transforms

Prova automatically applies bunch of transforms by looking at the file extension. If you'd like to use a transform that doesn't exist in Prova by default, you can choose it with a parameter;

$ node test -b -t coffeeify

Multiple transforms can be specified using comma;

$ node test -b -t coffeeify,brfs,foo,bar

Browserify Plugins

Pass Browserify plugins passing -u or --plugin parameter;

$ node test -b --plugin foo

Use comma to separate multiple plugins;

$ node test -b --plugin foo,bar

Custom Frame Documents

When you're running the tests on the browser, Prova has an empty HTML template that loads and runs the JavaScript tests. You can customize this HTML file with -f or --frame parameter:

$ node test -b -f test.html

Click the arrow button on right middle to keep the frame open. You'll be seeing the HTML document and test results in the same screen.

Manually Restarting Browser Tests

Prova watches for changes and automatically restarts the browser tests (inside in an iframe) but in case you need, there is an endpoint for restarting all the tests by hitting an endpoint;

$ curl localhost:7559/restart

Loading Assets

You may need to load your images, web workers etc. for testing. Prova allows you to load assets from your current directory via the /assets/in endpoint. Let's say you'd like to load a file called "foobar.png":

$ curl http://localhost:7559/assets/in/foobar.png

Should work for you.

HTTP Proxy

HTTP proxying is pretty useful to by-pass cross-domain issues (CORS) on the browser. You can easily point a URL to another host using -y / --http-proxy parameters:

$ node test -b -y "/my-api=http://localhost:8080"

Assuming that you'll be running your tests on :7559, any requests to /my-api will be streamed through localhost:8080 in the above example.

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      Publish 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.
          -f     --frame         Specify a custom document to run tests on browser. e.g node test -b -f custom.html
          -x     --exec          Execute given commmand before running the tests.
          -y     --http-proxy    Proxy requests matching with given pattern to a target. e.g -y "/images=localhost:8080"

          -t     --transform     Use given Browserify transforms. e.g node test -b -t coffeeify,brfs
          -u     --plugin        Use given Browserify plugins. e.g node test -b -u foo,bar

          -s     --progress      Show a progress bar. Useful when tests are running slow.

          -p     --tap           Output original Tap output without modifying anything.

          -C     --no-console    Disable showing browser console messages on command-line.

          -v     --version       Show version and exit
          -h     --help          Show help and exit
                 --examples      Show example commands

Example Commands

    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 -o 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

More Repositories

1

boxcars-archived

Easy-to-configure Static Web & Reverse Proxy Server in Go
Go
625
star
2

kaktus

Experimental web browser with minimalistic design
JavaScript
417
star
3

crud

Relational database library for SQL databases & Go.
Go
311
star
4

go-makefile-example

Example Makefile for Go projects
Makefile
265
star
5

emacs

Ready-to-use Emacs Setup for JavaScript and Go
Emacs Lisp
226
star
6

atlas

DEPRECATED: I'm using labstack/echo now.
Go
181
star
7

logger

Minimalistic logging library for Go.
Go
158
star
8

memdiff

BDD style memory leak hunting tool
JavaScript
153
star
9

yolo

File watcher with web UI.
Go
133
star
10

alert

JavaScript library to play sound alerts
JavaScript
111
star
11

mao

Pragmatic BDD Testing Framework For Go
Go
102
star
12

shell-jobs

Human-friendly Cron replacement in NodeJS
JavaScript
96
star
13

english-time

Parses times written in simple English to unix time.
JavaScript
88
star
14

relative-date

Javascript module for outputting relative dates.
JavaScript
81
star
15

functools

DEPRECATED: Use small modules instead
JavaScript
79
star
16

radio-paradise

Radio Paradise Client made with Elm and Go
JavaScript
76
star
17

play-audio

Lightweight Wrapper For HTML5 Audio API
JavaScript
70
star
18

developers-in-turkey

A list of Turkish provinces by the count of software developers.
JavaScript
66
star
19

lowkick

simplifies running javascript tests on varied environments, from command-line.
JavaScript
61
star
20

watch-array

Lets you subscribe to any changes on native JavaScript arrays.
JavaScript
59
star
21

distractions

A command-line tool to define distracting websites and turn them on/off when needed.
Shell
58
star
22

prova-retired

RETIRED Check out http://github.com/azer/prova
JavaScript
57
star
23

personal-api

NodeJS API server to publish personal info.
JavaScript
49
star
24

declarative-js

Declarative async programming with JavaScript
JavaScript
49
star
25

door

Minimalistic HTTP proxy server with config auto-reloading and static file serving.
JavaScript
47
star
26

indexeddb

Well-tested, low-level wrapper around the IndexedDB API. It can sync locally and remotely.
TypeScript
45
star
27

homepage

My personal website
JavaScript
39
star
28

html-patcher

Virtual DOM Diff & Patch with HTML Templates
JavaScript
35
star
29

environ

Cross-platform environment detection library for JavaScript
JavaScript
32
star
30

miso-emacs

Opinionated Emacs distro for minimalists.
Emacs Lisp
32
star
31

ourtunes

Roll your music player in a few minutes, with single command.
JavaScript
31
star
32

jsbuild

JSBuild is a command-line utility that provides building CommonJS modules and packages for web
Python
30
star
33

observer

CommonJS Implementation of the Observer Pattern
JavaScript
29
star
34

prettify-error

Prettify given error objects for console outputs
JavaScript
29
star
35

js-yasnippets

OUT OF DATE
28
star
36

.w3

A Google Chrome extension that executes JavaScript and CSS files in ~/.w3
D
27
star
37

debug

Tiny Debugging Tool For Golang
Go
27
star
38

get-object-path

Return the value at given object path.
JavaScript
23
star
39

toledo-chess

Unobtrusive, indented fork of Oscar Toledo's Javascript Chess
JavaScript
21
star
40

npm.el

Create and rule NPM packages from Emacs
Emacs Lisp
21
star
41

go-preact-starter

Starter for combining Go and Preact in any web project.
Go
20
star
42

play-url

Unified API for playing Youtube, Rdio, SoundCloud and Mp3 URLs.
JavaScript
19
star
43

remotely

Run given command remotely via SSH
JavaScript
18
star
44

new-list

Array-like objects with PubSub interfaces that you can subscribe to changes.
JavaScript
17
star
45

new-struct

Structs inspred from Golang
JavaScript
17
star
46

strip

Strip HTML Tags
JavaScript
17
star
47

gezi

Gezi Web Browser
JavaScript
17
star
48

render-loop

Async DOM render loop with Virtual DOM diffing
JavaScript
16
star
49

with-env

Read and apply .env file (if exists) in the working directory.
JavaScript
16
star
50

node-eksi-sozluk

NodeJS client to query Eksi Sozluk
JavaScript
16
star
51

javascript-guide

Azer's JavaScript Guide
16
star
52

measure-time

create benchmark suites and see the time consumption per given functions.
JavaScript
15
star
53

indexhtml

Generate a customized index.html file
JavaScript
15
star
54

highkick

HighKick is a small testing framework that I like.
JavaScript
15
star
55

juxt.js

Take a set of functions, return a function that is the juxtaposition of those functions.
JavaScript
14
star
56

7min.io

7min Workout App
JavaScript
13
star
57

pubsub

Minimalistic Pubsub Implementation
JavaScript
13
star
58

turkish-dictionary-api

API Server for the official Turkish-to-turkish dictionary by TDK
JavaScript
12
star
59

dotfiles

my dotfiles
Emacs Lisp
12
star
60

snakecase

Go library for converting given string to snake case
Go
12
star
61

new-chain

Create chaining APIs from functions
JavaScript
11
star
62

virtual-glue

Render HTML with Hyperglue and VirtualDOM
JavaScript
11
star
63

subscription

NodeJS library to simplify paid subscriptions with Stripe and LevelDB.
JavaScript
11
star
64

go-choo-starter

Starter for choo projects with Go backend.
Go
10
star
65

run-after

Run a command after given time based on english-time
Ruby
10
star
66

format-text

String formatting library inspired from Python
JavaScript
10
star
67

ethereum-tipping-wallet

Chrome extension for tipping websites with Ethereum
TypeScript
10
star
68

style-format

Library to easily style texts with string formatting.
JavaScript
10
star
69

remote-control

Run remote commands in a web page via HTTP requests.
JavaScript
10
star
70

go-style

Console styling library for Golang
Go
10
star
71

redux-starter

Hek Module for Redux
JavaScript
10
star
72

require-sdk

JavaScript library for making sure given SDK is loaded and executed. Designed for popular APIs like Youtube, Rdio, Soundcloud etc.
JavaScript
9
star
73

afrikaradyo.com

JavaScript
9
star
74

after-time

Declarative setTimeout
JavaScript
8
star
75

expand-home-dir

Expand ~/
JavaScript
8
star
76

scrape-url

Scrape URLs with CSS selectors
JavaScript
8
star
77

new-object

Objects that you can subscribe to changes.
JavaScript
8
star
78

new-command

Simplifies creating CLI programs by combining minimist, show-help, show-version modules.
JavaScript
8
star
79

flat-glob

Return glob applied, flattened and duplicate filtered version of the given list of filenames
JavaScript
8
star
80

concat

Concatenate files
JavaScript
7
star
81

right-pad

string right pad
JavaScript
7
star
82

roka

High-level styling library for React
TypeScript
7
star
83

attr

Observable Attributes
JavaScript
7
star
84

title-from-url

Generate a title from given URL
JavaScript
7
star
85

styled

console styling library
JavaScript
7
star
86

domloader

JavaScript
7
star
87

genpkg

Generate NodeJS Packages from JavaScript files
JavaScript
7
star
88

next-time

Returns the nearest date of given time
JavaScript
7
star
89

chessboard

Pure HTML&XSLT Chess Board with FEN Support
6
star
90

logger-slack-hook

Slack hook for logger library
Go
6
star
91

deprecated-roka

[deprecated] A new javascript framework targeting modern web/javascript engines
JavaScript
6
star
92

memoize-async

Async Function Memoizer
JavaScript
6
star
93

anglicize

Anglicize the special characters in given text
JavaScript
6
star
94

urls

URL Library for Kaktüs
JavaScript
6
star
95

delicious-surf

a web browser for better bookmarking
C
6
star
96

duba

CLI tool for managing multiple remote and local workspaces using SSH
JavaScript
5
star
97

elm-ui-styles

UI Library for Elm, inspired by Tachyons.
Elm
5
star
98

anakaynak.com

anakaynak.com source code
JavaScript
5
star
99

flatten-array

Flattens nested arrays.
JavaScript
5
star
100

vimfiles

My VIM Configuration Files
Vim Script
5
star