This is development (master) version.
For production version (relase) see
http://github.com/cyrhla/tester/tree/v0.0.1
- Version: 0.0.1-dev
- Technologies:
- JavaScript
- Copyright / Authors:
- Krystian Pietruszka kpietru@cyrhla.com
- Licenses:
- Download: http://github.com/cyrhla/tester/releases
- Homepage: http://www.cyrhla.com
- More: package.json
The "tester" is a simple JavaScript test module.
npm install @cyrhla/tester
First, create the class:
// SomeClass.js
class SomeClass
{
someMethod(someArgument)
{
return someArgument + '...'
}
// ...
}
Second, create the test:
// Tests/SomeClassTest.js
const Tester = require('@cyrhla/tester/Tester')
const SomeClass = require('../SomeClass')
class SomeClassTest extend Tester
{
testSomeMethodReturnsString()
{
var obj = new SomeClass()
this.assertSame('abc...', obj.someMethod('abc'))
}
// ...
}
Third, create the script*:
// scripts/test.js
'use strict'
new (require('@some/module/Tests/SomeClassTest'))()
Fourth, add the following lines to the package.json:
// ...
scripts: {
"test": "node scripts/test.js"
}
// ...
Finally, execute the command via shell:
npm test
// somefile.js
const is = require('@cyrhla/tester/is')
var somefunc = function(arg) {
if (is(arg, 'string', 'number')) {
// ...
}
// ...
}
// ...
// somefile.js
const valid = require('@cyrhla/tester/valid')
var somefunc = function(arg) {
valid(arg, 'string', 'number')
// ...
}
// ...
- Tester( boolean: stopOnError = false, boolean: showOk = false, boolean: colorize = true, null|function|console.log: output = console.log )
- toString(): string
- getResultsJson: object
- before(): undefined
- after(): undefined
- beforeEach(): undefined
- afterEach(): undefined
- assertSame( mixed: expected, mixed: actual ): undefined
- assertEqual( mixed: expected, mixed: actual ): undefined
- assertType( string: expected, mixed: actual ): undefined
- assertInstanceOf( function: expected, function|object: actual ): undefined
- assertError( string: errorName, function: callback, null|number: index = null ): undefined
- createMocker( function: baseClass, mixed[]: args ): Mocker
- static getBacktrace( Error: error, null|number: back = null ): string
- static formatBytes( number: bytes, number: decimals = 1, string: separator = '.', number: kilo = 1000, string[]: units = [Bytes, KB, MB, GB, TB, PB, EB, ZB, YB] ): string
- static type( mixed: arg ): string
- static valid( *, *, ... ): mixed
- static is( *, *, ... ): boolean
- Mocker( function: baseClass, mixed[]: args = [] )
- setProperty( mixed: key, mixed: value ): self
- setMethod( mixed: key, function: callback ): self
- compile(): object
is( *, *, ... ): boolean
valid( *, *, ... ): mixed
[*] Paths should be modified to the module.