Skip to content

kznrluk/morse-unit-test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Morse Unit Test Runner

errors

Morse is a simple, easy, fast unit test runner for JavaScript / TypeScript.

日本語のドキュメントはこちら

Why Morse?

  • No extra command
  • No complex document
  • Tiny architecture
  • High speed operation by parallel test execution
  • Easy-to-read test results
  • Async function support
  • Zero runtime dependencies
  • Easy to extend because it is based on the default functions of JS

How to Use

Morse provides only a minimal test environment.

#1 Install

You can install from npm command.

npm install --save-dev morse-unit-test

#2 Write a test

Tests can be run on any directory or file. Tests are defined as functions in objects.

Tests can use regular functions as well as asynchronous functions using async / await.

// import { doTest } from 'Morse';
const Morse = require('Morse');

const tests = {
    'Test to be failed': (assert) => {
        assert(2, 1); // failed
        // assert(false) // Same as above
    },
    
    'Test to be passed': (assert) => {
        assert(2, 1+1); // passed
        // assert(true) // Same as above
    },

    'Test async function': async () => {
        const result = await someAsyncFunction();
        assert(result !== undefined);
    }
}

Morse.doTest(tests);

Currently, the order of testing is not guaranteed. In particular, when performing tests using async / await, the order may change.

#3 Run the test

Execute directly with the node command.

node yourTest.js

The results are displayed in the console.

Example Output

How to check test results

Console

There are 4 types of assertion results:

  • PASSED (.) Test completed without any problems.
  • FAILED (F) test result did not match expected value.
  • ERROR (E) An exception occurred during the test operation.
  • UNSAFE (U) The test completed successfully, but no assertions were performed.

About

Simple, easy, fast unit test runner for JavaScript / TypeScript

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published