Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript. Learn more »

scar

0.8.0 • Public • Published

scar

license web github npm
version downloads dependencies status build status

A test runner for Node.js and the browser. Extensively tested with mocha and scar itself.

Install

> npm install [-D] scar

Examples

Have a look at folder test/scar, scar is tested with scar too. For async tests return a promise.

node

works fine with node, webpack+babel, browserify+babel

const {test, assert} = require('scar');
 
test('passing', () => {
    assert.equal(1, 1);
});
 
test('failing', () => {
    assert.equal(1, 2);
});
 
test.cli();

browser / ES5

might need additional polyfills to work in older browsers

  • Promise
  • Object.assign
  • Array.prototype.every
<script src="scar.js"></script>
<script>
    var test = window.scar.test;
    var assert = window.scar.assert;
 
    test('passing', function () {
        assert.equal(1, 1);
    });
 
    test('failing', function () {
        assert.equal(1, 2);
    });
 
    test.cli();
</script> 

CLI

scar - a test runner for node and the browser

Usage:
  node your-script.js [opt...] [arg...]
  your-url.html?opt&...&arg&...

Options:
  -h: show this help message
  -t: show test stats

Arguments:
  all arguments are used as test filters

API

scar

const obj = require('scar') // nodejs
var obj = window.scar // browser

then obj is

{
    Scar, // constructor
    test, // preconstructed Scar().static()
    assert, // lightweight assertions
    insp // lightweight value inspection
}

test

test(desc, fn, {skip, sync}) // args optional and in any order
test.skip(desc, fn, {sync}) // implies `skip: true`
test.sync(desc, fn, {skip}) // implies `sync: true`
test.run() // run all tests with default reporter => Promise()
test.cli() // run CLI with default reporter => Promise()
test.scar // scar instance

assert

assert(expr, msg) // !!expr === true
assert.fail(msg)
assert.ok(act, msg) // !!act === true
assert.notOk(act, msg) // !act === true
assert.equal(act, exp, msg) // act === exp
assert.notEqual(act, ref, msg) // act !== ref
assert.deepEqual(act, exp, msg) // act === exp for all but Array and plain Object
assert.notDeepEqual(act, ref, msg) // !deepEqual()
assert.throws(fn, exp, msg)
assert.rejects(thenable, exp, msg) // => Promise

insp

insp(x) // => string repr of x

License

The MIT License (MIT)

Copyright (c) 2015 Lars Jung (https://larsjung.de)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Keywords

none

install

npm i scar

Downloadsweekly downloads

35

version

0.8.0

license

MIT

homepage

larsjung.de

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability