united-tests

This is a tool that can automate and validate unit tests.

Usage no npm install needed!

<script type="module">
  import unitedTests from 'https://cdn.skypack.dev/united-tests';
</script>

README

united-tests

This is a tool that can automate and validate unit tests.

Why use them?

Because this is a lightweight and powerful unit test gadget, and we will continue to maintain it in the future.

Download

Download with npm

sudo npm install united-tests -g

Download with yarn

sudo yarn add united-tests -g

Usage

unitedt [options]

Flags

  • -h, --help: output usage information
  • -V, --version: output the version number
  • -e, --error: show detailed error message when got error
  • -o, --out: open test-out flag
  • -f, --fuzzy: Open fuzzy query (the fuzzy mode is in the form of regular expression)
  • -i, --info [filename]: Set the out info json file (default: "tests-info.json")
  • -j, --json [filename]: Set the entry json file (default: "tests.json")

Example

tests.json

{
  "test-out": false,
  "tests": [
    {
      "name": "hello",
      "run": {
        "inputs": [
          []
        ],
        "outputs": [
          "Hello world!"
        ]
      }
    }
  ]
}
unitedt

Edit tests.json

Basic structure

{
  "test-out": "boolean (default: false)",
  "out-in-json": "boolean (default: false)",
  "fuzzy": "boolean (default: false)",
  "out-json-name": "string (default: \"tests-info.json\")",
  "read-dir": "string (default: \"tests\")",
  "tests": "array"
}

Prototypes

  • test-out Set whether to output the result of the test module
  • out-in-json Set whether to output the test results and summary to the json file
  • out-json-name Set json filename
  • fuzzy Whether to enable fuzzy query (the fuzzy mode is in the form of regular expression)
  • read-dir Set the path to the unit test summary
  • tests Set up each module that the unit test needs to test and its input and output samples

Element of tests

{
  "name": "string",
  "run": {
    "inputs": "array",
    "outputs": "array"
  }
}

Issues

Issues-1

internal/modules/cjs/loader.js:611
    throw err;
    ^

Error: Cannot find module 'commander'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:609:15)
    at Function.Module._load (internal/modules/cjs/loader.js:535:25)
    at Module.require (internal/modules/cjs/loader.js:663:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/united-tests/bin/main.js:2:15)
    at Module._compile (internal/modules/cjs/loader.js:734:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:745:10)
    at Module.load (internal/modules/cjs/loader.js:626:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:566:12)
    at Function.Module._load (internal/modules/cjs/loader.js:558:3)

This shows that the command line tool is missing the npm package commander. Enter sudo npm install commander -g on the command line to solve

Issues-2

       throw err;
       ^
   
   Error: Cannot find module 'chalk'
       at Function.Module._resolveFilename (internal/modules/cjs/loader.js:609:15)
       at Function.Module._load (internal/modules/cjs/loader.js:535:25)
       at Module.require (internal/modules/cjs/loader.js:663:17)
       at require (internal/modules/cjs/helpers.js:20:18)
       at Object.<anonymous> (/usr/local/lib/node_modules/united-tests/bin/main.js:3:15)
       at Module._compile (internal/modules/cjs/loader.js:734:30)
       at Object.Module._extensions..js (internal/modules/cjs/loader.js:745:10)
       at Module.load (internal/modules/cjs/loader.js:626:32)
       at tryModuleLoad (internal/modules/cjs/loader.js:566:12)
       at Function.Module._load (internal/modules/cjs/loader.js:558:3)

This shows that the command line tool is missing the npm package chalk. Enter sudo npm install chalk -g on the command line to solve

License

MIT