3.2.1 • Published 1 year ago

betest v3.2.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Betest

Betest is a small and simple way to write and run JavaScript tests with zero dependencies!

Table of content

Installation

npm install betest --save-dev

For beta see Github

npm install betest@beta --save-dev

Usage

Assuming that you have folder "tests" and file "index.js" inside.

node ./tests/index.js

or add this to your package.json

  "scripts": {
    "test": "node ./tests/index.js"
  },

Example

Create an instance of Betest:

import {Betest} from 'betest';

const betest = new Betest();

You can choose how results will be look in console using parameters object:

betestParams = {
    results: {
        showAs: "Table" // or "Line"(Colorful PASS/FAIL)
    }
}
const betest = new Betest(betestParams);

Add your named group and functions using method "addGroup":

betest.addGroup(
    { 
        name: "Example Group", 
        tests: [
            {   
                expected: {
                    fisrstName: "First Name",
                    secondName: "Second Name"
                },
                test: function checkObject() {
                    return {
                    fisrstName: "First Name",
                    secondName: "Second Name"
                    }
                }
            },
            {   
                expected: 7,
                test: function findHypotenuse() {
                    return Math.round(Math.sqrt(5 ** 2 + 5 ** 2));
                }
            },
            {   
                expected: [
                    [6, -8, 1],
                    [4, 1, 0],
                    [2, 3, 5]
                ],
                test: function checkArrayEquality() {
                    return [
                        [6, -8, 1],
                        [4, 1, 0],
                        [2, 3, 5]
                    ]
                }
            }
        ]
    }
);

You can run all tests in all groups, either one group or only one test in the group: 1. Run all tests in all groups

betest.runAll();
  1. Run only one group's tests
betest.runGroup("Example Group");
  1. Run only one test in the group
betest.runTest("Example Group", "findHypotenuse");

Or you can run test on the fly

betest.go(
    [ // groups
        { // one group
            tests: {
                expected: 1,
                test: function findSinus() {
                    return Math.sin(90 * 180 / Math.PI);
                }
            }
        }
    ]
);

And see results:

(index)(name)Values
0multiplicationtrue
1sumtrue

Constructor Params

const betestParams = {
    results: {
        // 1. "Table" for table result.
        // 2. "Line" for colorful PASS/FAIL message
        showAs: string
    }
}
3.2.1

1 year ago

3.1.2

1 year ago

3.2.0

1 year ago

3.1.1

1 year ago

3.1.0

1 year ago

2.0.1

2 years ago

3.0.0

2 years ago

2.0.0-beta.2

2 years ago

2.0.0-beta.1

2 years ago

2.0.0-beta.4

2 years ago

2.0.0

2 years ago

2.0.0-beta.3

2 years ago

1.2.17

2 years ago

1.2.16

2 years ago

1.2.15

2 years ago

1.2.14

2 years ago

1.2.13

2 years ago

1.2.12

2 years ago

1.2.11

2 years ago

1.2.10

2 years ago

1.2.9

2 years ago

1.2.8

2 years ago

1.2.7

2 years ago

1.2.6

2 years ago

1.2.5

2 years ago

1.2.4

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

1.1.0

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago