Gathering detailed insights and metrics for dotest
Gathering detailed insights and metrics for dotest
Gathering detailed insights and metrics for dotest
Gathering detailed insights and metrics for dotest
npm install dotest
Typescript
Module System
Min. Node Version
Node Version
NPM Version
JavaScript (93.52%)
Shell (6.48%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
Unlicense License
1 Stars
556 Commits
1 Forks
2 Watchers
2 Branches
2 Contributors
Updated on Mar 28, 2025
Latest Version
2.14.0
Package Id
dotest@2.14.0
Unpacked Size
44.84 kB
Size
10.37 kB
File Count
6
NPM Version
10.9.2
Node Version
23.10.0
Published on
Mar 28, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
One dev dependency for your Node.js package to run ESLint, your test.js, coverage and report to Coveralls.io when running in a CI environment.
eslint.config.mjs
filetest.js
with nyc
to generate a coverage reporttest.js
1// Load test runner and your app 2const doTest = require( 'dotest' ); 3const app = require( './' ); 4 5// Check app interface 6doTest.add( 'App interface', test => { 7 test() 8 .isFunction( 'fail', 'methodOne', app.methodOne ) 9 .isObject( 'fail', 'sub', app.sub ) 10 .isFunction( 'fail', 'sub.methodTwo', app.sub.methodTwo ) 11 .done() 12 ; 13} ); 14 15// Check method response 16doTest.add( 'App methodOne', test => { 17 app.methodOne( ( err, data ) => { 18 test( err ) 19 .isObject( 'fail', 'Callback data', data ) 20 .isArray( 'fail', 'data.music', data.music ) 21 .isNotEmpty( 'warn', 'data.music', data.music ) 22 .done() 23 ; 24 } ); 25} ); 26 27// Check promise 28doTest.add( 'Promise good', async test => { 29 let error; 30 let data; 31 32 try { 33 data = await myPromise(); 34 } 35 catch ( err ) { 36 error = err; 37 } 38 39 test( error ) 40 .isObject( 'fail', 'data', data ); 41 .done() 42 ; 43} ); 44 45// Run the tests 46doTest.run();
package.json
Full test including ESLint, test.js, coverage report and Coveralls.io submit.
1"scripts": { 2 "test": "dotest" 3}
Or just run your test.js
1"scripts": { 2 "test": "node test.js" 3}
Just run npm test
This is usually intended for CI builds,
so best to make sure it's in your devDependencies
1npm i dotest --save-dev
The script takes these env variables. They override the code settings.
name | default | description |
---|---|---|
[DOTEST_WAIT] | 0 | Pause N ms between tests |
[DOTEST_NOCOV] | Set to 'true' to skip coverage report | |
[DOTEST_MINCOV] | 85 | Minimum coverage % default |
[DOTEST_COVBRANCHES] | $DOTEST_MINCOV | Minimum coverage % for branches |
[DOTEST_COVLINES] | $DOTEST_MINCOV | Minimum coverage % for lines |
[DOTEST_COVFUNCTIONS] | $DOTEST_MINCOV | Minimum coverage % for functions |
[DOTEST_COVSTATEMENTS] | $DOTEST_MINCOV | Minimum coverage % for statements |
( label, testFunction )
Add a new test to the queue.
1doTest.add( 'App interface', test => { 2 test() 3 .isArray( 'fail', 'my array', [] ) 4 .done() 5 ; 6} );
( [wait] )
Run the tests from the queue, one by one.
param | type | default | description |
---|---|---|---|
[wait] | number | 0 | Wait N ms between tests |
1// Normal, without pause between tests 2doTest.run(); 3 4// Or wait 2 seconds 5doTest.run( 2000 );
( [type], str, [dontCount] )
Fancy console.log
with style.
param | type | default | description |
---|---|---|---|
[type] | string | plain | Text style to apply, see below |
str | string | The string to output | |
[dontCount] | boolean | false | Don't count a fail or error towards the exit status |
style | description |
---|---|
fail | FAIL Text with FAIL in red |
good | good Text with good in green |
warn | warn Text with warn in yellow |
info | info Text with info in cyan |
note | Text with Text in bold |
error | ERROR Error.message\nError\nError.stack with ERROR in red |
plain | No styling |
The styles error
, fail
and warn
add to the errors and warnings counters,
where error
and fail
also cause the script to fail.
1// Bold text 2doTest.log( 'note', 'Hello world' );
( )
Force exit the process, after writing statistics to the console.
1doTest.exit();
( [err] )
Returns check functions.
Optionally test for err
instance of Error
and dump it to the console.
The check functions take a level
parameter.
When set to fail
the check reports fail and the whole test script will eventually fail.
When set to warn
the check reports warn but won't cause the script to fail.
You can concat the check functions for clean code.
1// Using the method 2doTest.add( 'App interface', () => { 3 doTest.test() 4 .isObject( 'fail', 'Callback data', data ) 5 .done() 6 ; 7} ); 8 9// Or using the shortcut 10doTest.add( 'App interface', test => { 11 test() 12 .isObject( 'fail', 'Callback data', data ) 13 .done() 14 ; 15} );
( [callback] )
Run the next test from the queue.
Optionally run a callback
function before the next test.
See example above.
( )
Alias to dotest.exit().
Works similar to .done()
where it ends the test,
but .exit()
also ends the whole script.
1test() 2 .isArray( 'fail', 'data', [] ) 3 .exit() 4;
( message )
Output 'info' log line.
The message
can be of any type.
When it is not a string, the type is written instead
and the full value of message
dumped right below.
1test() 2 .info( { hello: 'world' } ) 3 .done() 4; 5 6// Output: 7// info Object 8// { hello: 'world' }
( message )
Output 'good' log line.
The message
can be of any type.
When it is not a string, the type is written instead
and the full value of message
dumped right below.
1test() 2 .good( 'It works great' ) 3 .done() 4; 5 6// Output: 7// good It works great
( message )
Output 'warn' log line.
The message
can be of any type.
When it is not a string, the type is written instead
and the full value of message
dumped right below.
1test() 2 .warn( 'Hmm something odd happened' ) 3 .done() 4; 5 6// Output: 7// warn Hmm something odd happend
( message, [dontCount] )
Output 'FAIL' log line.
The message
can be of any type.
When it is not a string, the type is written instead
and the full value of message
dumped right below.
1test() 2 .fail( 'We have a problem' ) 3 .done() 4; 5 6// Output: 7// FAIL We have a problem
( err, [dontCount] )
Output 'ERROR' log line with dump and stack trace.
1const err = new Error( 'Oops' ); 2 3test() 4 .error( err ) 5 .done() 6; 7 8// Output: 9// ERROR Oops 10// 11// [Error: Oops] 12// ...
( level, what, input )
Check if input
is an instance of Error.
param | type | description |
---|---|---|
level | string | Either fail or warn |
what | string | Text to prepend to check result |
input | mixed | The variable to check |
1test() 2 .isError( 'fail', 'My data', data ) 3 .done() 4;
( level, what, input )
Check if input
is an instance of Object.
param | type | description |
---|---|---|
level | string | Either fail or warn |
what | string | Text to prepend to check result |
input | mixed | The variable to check |
1test() 2 .isObject( 'fail', 'My data', data ) 3 .done() 4;
( level, what, input )
Check if input
is an instance of Array.
param | type | description |
---|---|---|
level | string | Either fail or warn |
what | string | Text to prepend to check result |
input | mixed | The variable to check |
1test() 2 .isArray( 'fail', 'My data', data ) 3 .done() 4;
( level, what, input )
Check if input
is a string.
param | type | description |
---|---|---|
level | string | Either fail or warn |
what | string | Text to prepend to check result |
input | mixed | The variable to check |
1test() 2 .isString( 'fail', 'My data', data ) 3 .done() 4;
( level, what, input )
Check if input
is a number.
param | type | description |
---|---|---|
level | string | Either fail or warn |
what | string | Text to prepend to check result |
input | mixed | The variable to check |
1test() 2 .isNumber( 'fail', 'My data', data ) 3 .done() 4;
( level, what, input )
Check if input
is undefined.
param | type | description |
---|---|---|
level | string | Either fail or warn |
what | string | Text to prepend to check result |
input | mixed | The variable to check |
1function ( err, data ) { 2 test() 3 .isUndefined( 'warn', 'My data', data ) 4 .done() 5 ; 6}
( level, what, input )
Check if input
is null.
param | type | description |
---|---|---|
level | string | Either fail or warn |
what | string | Text to prepend to check result |
input | mixed | The variable to check |
1function ( err, data ) { 2 test() 3 .isNull( 'warn', 'My data', data ) 4 .done() 5 ; 6}
( level, what, input )
Check if input
is NaN.
param | type | description |
---|---|---|
level | string | Either fail or warn |
what | string | Text to prepend to check result |
input | mixed | The variable to check |
1function ( err, data ) { 2 test() 3 .isNaN( 'warn', 'My data', data ) 4 .done() 5 ; 6}
( level, what, input )
Check if input
is a boolean.
param | type | description |
---|---|---|
level | string | Either fail or warn |
what | string | Text to prepend to check result |
input | mixed | The variable to check |
1test() 2 .isBoolean( 'fail', 'My data', data ) 3 .done() 4;
( level, what, input )
Check if input
is an instance of Function or AsyncFunction.
param | type | description |
---|---|---|
level | string | Either fail or warn |
what | string | Text to prepend to check result |
input | mixed | The variable to check |
1test() 2 .isFunction( 'fail', 'My data', data ) 3 .done() 4;
( level, what, input )
Check if input
is an instance of Function.
param | type | description |
---|---|---|
level | string | Either fail or warn |
what | string | Text to prepend to check result |
input | mixed | The variable to check |
1test() 2 .isFunction( 'fail', 'My data', data ) 3 .done() 4;
( level, what, input )
Check if input
is an instance of AsyncFunction.
param | type | description |
---|---|---|
level | string | Either fail or warn |
what | string | Text to prepend to check result |
input | mixed | The variable to check |
1test() 2 .isAsyncFunction( 'fail', 'My data', data ) 3 .done() 4;
( level, what, input )
Check if input
is an instance of Date.
param | type | description |
---|---|---|
level | string | Either fail or warn |
what | string | Text to prepend to check result |
input | mixed | The variable to check |
1const myDate = new Date(); 2 3test() 4 .isDate( 'fail', 'My data', myDate ) 5 .done() 6;
( level, what, one, two )
Check if one
is exactly of the same type and value as two
.
param | type | description |
---|---|---|
level | string | Either fail or warn |
what | string | Text to prepend to check result |
one | mixed | The variable to check |
two | mixed | The variable to check against |
1test() 2 .isExactly( 'fail', 'My data', 'foo', 'bar' ) 3 .done() 4;
( level, what, one, operator, two )
Check if the two values meet the condition.
param | type | description |
---|---|---|
level | string | Either fail or warn |
what | string | Text to prepend to check result |
one | mixed | Variable to test against |
operator | string | < , > , <= , >= |
two | mixed | Variable to test against |
1test() 2 .isCondition( 'fail', 'My data', 1, '<', 2 ) 3 .done() 4;
( level, what, input )
Check if input
is undefined, null, or an empty string, object, array or Error.
In case of Error the input.message
and Object.keys( input )
are checked.
param | type | description |
---|---|---|
level | string | Either fail or warn |
what | string | Text to prepend to check result |
input | mixed | The variable to check |
1// Object is empty 2test() 3 .isEmpty( 'fail', 'My data', {} ) 4 .done() 5;
( level, what, input )
Check if input
is not undefined, null, or an empty string, object, array or Error.
In case of Error the input.message
and Object.keys( input )
are checked.
param | type | description |
---|---|---|
level | string | Either fail or warn |
what | string | Text to prepend to check result |
input | mixed | The variable to check |
1// Object is not empty 2test() 3 .isNotEmpty( 'fail', 'My data', { foo: 'bar' } ) 4 .done() 5;
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.
In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.
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 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.
For more information, please refer to https://unlicense.org
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
security policy file detected
Details
Reason
SAST tool detected but not run on all commits
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/25 approved changesets -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More