testease v1.0.4
TestEase
An NPM repository to ease the testing of Node projects, where instead of writing whole test files,you only need to define the testcases with path, function name, input, and expected output, saving a lot of time in writing testcases, and focusing more on your product, or project.
Usage
To install the package,
npm i -g testease
testease
NOTE: This package is to be installed globally
Documentation
File specifiication
{
"name": "testease",
"functions": [
{
"path": "Path to file",
"describe":"optional description of your testcase to better track your tests",
"name": "Name of the function ( if no name given, file is assumed to export a function",
"input": [
"variables",
"in",
"order"
],
"returnFunctionType": "promise OR value",
"returnType": "Type of data returned",
"returnValue": "Value of data"
}
]
}
functions
is an array where the testcases need to be defined, along with the path to the module, name of the function if any, input, and also specifying the return type of the function, such as whether the return type is a value, or a promise, and type of the data returned.
NOTE: path
must be defined from the base of the project, or where the testease.json resides, i.e. where testease was called initially. The starting `.
must be avoided.
Type of entries
Attribute | typeof | Significance |
---|---|---|
path | string | Path to the module |
name | string | Name of function, if not given, module is expected to export only one function |
input | list | List of variables in order of declaration in function |
returnFunctionType | string | Type of return promise / value |
returnType | string | Type of value returned i.e. number, string, boolean, etc. |
returnValue | any | Value, in the type it is to be returned |
In case the return type is an object
"returnType": {
"success": "boolean",
"message": "string"
},
"returnValue": {
"success": false
}
Returned types can be defined, and if they aren't defined, it will throw an error. If it not defined in returnValue, and if it is of the type in returnType, it will not throw an error.
NOTE: Returned objects supported
Command line options
testease --help
ortestease -h
- Get more information on the command line options
testease init
- Create the default testease.json file where the testcases need to be entered
testease test
- Test against testcases defined in testease.json
Additional command line options
--logs BOOL
- Specify to include logging or not
--log-file FILEPATH
- Specify file path if you want to log to a file