pull-test v1.2.3
pull-test
run assertion tests using pull streams
npm install --save-dev pull-testexample
// example.js
module.exports = {
'it succeeds': function (assert) {
assert(true)
},
'it fails!': function (assert) {
assert(false)
},
'it errors!': function (assert, cb) {
cb(new Error('error'))
}
}pull-test example.js
✔ it succeeds
✖ it fails!
{ AssertionError: false == true
at tests (pull-test/example.js:9:5)
name: 'AssertionError',
actual: false,
expected: true,
operator: '==',
message: 'false == true',
generatedMessage: true }
▲ test runner ended with an error
Error: error
at tests (pull-test/example.js:12:8)cli
if test/*.js represents a set of files exporting tests,
runs these tests using built-in assert and default reporter with:
pull-test test/*.jsapi
test = require('pull-test')
test(tests)
runs tests using built-in assert and default reporter.
testSource = test.from(tests)
creates a source pull stream of test objects,
from any of the following format of tests:
function testTheThing (assert, cb) {
assert(true), cb()
}{
['test the thing']: function (assert, cb) {
assert(true), cb()
}
}[{
name: 'test the thing',
test: function (assert, cb) {
assert(true), cb()
}
}]through = test.Tester(options)
creates a through pull stream,
which expects to receive test objects with shape:
name: name of the testtest: function which receives(assert, cb). assert is the same as the node coreassertmodule and automatically collects errors.cbis to be called when the test is done, or the test runner has errored (it will close the stream with the error).
and will return test result objects with shape:
name: name of testassertions: array of assertions results from running test. eithertrueif assertion passed or an instance ofassert.AssertionErrorif assertion failed.duration: number of microseconds that test took to run
sink = test.Reporter(options)
creates a sink pull stream,
which receives test result objects and logs to the console.
license
The Apache License
Copyright © 2016 Michael Williams
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.