# sirrobert-test-vows

> A more terse DSL around the Vows testing module.

Latest version **1.3.7** (published 2016-10-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install sirrobert-test-vows
pnpm add sirrobert-test-vows
yarn add sirrobert-test-vows
bun add sirrobert-test-vows
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.7 |
| Published | 2016-10-21 |
| First published | 2016-09-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| Author | Sir Robert Burbridge |
| Maintainers | sirrobert |
| Keywords | unit-test, vows, test, testing |

## Links

- npm: https://www.npmjs.com/package/sirrobert-test-vows
- Repository: git@bitbucket.com:sirrobert/nodejs-test
- npm.io page: https://npm.io/package/sirrobert-test-vows

## Dependencies (2)

- [vows](https://npm.io/package/vows.md) ^0.8.1
- [deepcopy](https://npm.io/package/deepcopy.md) ^0.6.3

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [vest](https://npm.io/package/vest.md) — 50.1K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads

## Recent versions

- 1.3.7 (latest) — 2016-10-21
- 1.3.6 — 2016-10-21
- 1.3.4 — 2016-10-21
- 1.3.3 — 2016-10-21
- 1.3.0 — 2016-10-21
- 1.0.0 — 2016-09-29

## README

Rationale
=========

This is a thin wrapper around vows.  I didn't like how verbose vows is, but
I like the async features.

Installation
============

Local installation

    npm install --save sirrobert-test-vows

Global installation

    npm install --global sirrobert-test-vows

Usage
=====

Comparison with Vows
--------------------

For a full description of vows, you should check out [the vows website](http://vowsjs.org).  Here's a brief comparison, though.

The vows site gives a brief example of testing some division by zero errors:

    // division-by-zero-test.js

    var vows = require('vows'),
        assert = require('assert');

    // Create a Test Suite
    vows.describe('Division by Zero').addBatch({
        'when dividing a number by zero': {
            topic: function () { return 42 / 0 },

            'we get Infinity': function (topic) {
                assert.equal (topic, Infinity);
            }
        },
        'but when dividing zero by zero': {
            topic: function () { return 0 / 0 },

            'we get a value which': {
                'is not a number': function (topic) {
                    assert.isNaN (topic);
                },
                'is not equal to itself': function (topic) {
                    assert.notEqual (topic, topic);
                }
            }
        }
    }).run(); // Run it

Here's the same thing using this DSL.  I've left the same comments so it doesn't get shorter for cheaty reasons.

    // division-by-zero-test.js

    var Test = require("sirrobert-test-vows");

    // Create a Test Suite
    new Test(
      "Division by Zero",
      { when: "dividing a number by zero",
        using: () => 42/0,
        "we get Infinity": result => Test.is.equal(result, Infinity)
      },
      { when: "dividing zero by zero",
        using: () => 0/0,
        "we get a value which": {
          "is not a number":        result => Test.it.isNaN(result),
          "is not equal to itself": result => Test.is.notEqual(result,result),
        }
      }
    ).run(module); // Run it

In my opinion, this is much more readable.  Mainly because I don't relate to
the "vows", "topic", "batch" language in vows, but also because it reads
approximately like a sentence:

    Test
      "blah blah"

        when "blah blah"
        using <some method>
        "result 1" <by this means>,
        "result 2" <by this means>,
        "result 3" <by this means>,

        when "blah blah"
        using <some method>
        "result 1" <by this means>,
        "result 2" <by this means>,
        "result 3" <by this means>,

Sugar
-----

This module also smuggles in node's `assert` module so you don't have to
import it yourself.  You can, of course.  There's some sugar to make it a
little sweeter:  you can write short sentences with the module for your
assertions.

    Test.is(...);
    Test.is.equal(...);
    Test.is.StrictEqual(...);
    Test.it.doesNotThrow(...);
    Test.does.fail(...);

all three objects (`.is`, `.it`, and `.does`) are just synonyms for the
assert module.  That means these are all exactly equivalent:

    Test.is.equal(...);
    Test.it.equal(...);
    Test.does.equal(...);

... and so on for all other assert features.

How it Works
============

Dead simple, it just takes the data structure provided here and re-arranges
it slightly to be the vows infrastructure.  The source is a couple dozen
lines, so reading that will probably be an easier way to understand it.

---
_Source: https://npm.io/package/sirrobert-test-vows · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
