Home

Awesome

OwnTest

Simple JavaScript Testing Framework with only single file, zero dependencies and zero configuration.

Usage:

	owntest [options]

Options:

	init            : initialize ownTest

	--test          : run a single test file

	-h | --help     : show help

	-v | --version  : show version

To Use

  1. Initialize your ownTest project:
node owntest.js init
  1. Create test file with format name.test.js

You can put file in any folder but recommended on __test__.

  1. Write test code in test file.
  2. Run your test file:
    • Run owntest.js to run all test.
    • Run owntest.js --test=name.test.js to run single test.

Example Usage

You can see all example in example folder or see Owntest Example.

Configuration

You can configure your ownTest by following steps:

  1. create owntest.config.json file in your project root folder.
  2. edit owntest.config.json file as following:
    • "testPath": "__test__" - path to test folder.
    • "testIgnore": ["node_modules"] - list of folder to ignore.
    • "mode": "production" - mode of your ownTest.
    • "autoUpdate": true | false - auto update your ownTest.
  3. run owntest.js to run all test.

Setup and Teardown

OwnTest provides function to handle setup and teardown, you can use it in your test file for setup work that needs to happen before each test and teardown work that needs to happen after each test.

Repeating Setup

beforeEach(() => {
	/** put your function or variable here */
});

afterEach(() => {
	/** put your function or variable here */
});

One-Time Setup

beforeAll(() => {
	/** put your function or variable here */
});

afterAll(() => {
	/** put your function or variable here */
});

Expect

Expect to give you access to a number of "matches" that will allow you to validate things, including several methods.

Methods

All of the methods below can be used with a negation format like not(), example:


// normal

expect(1).toBe(1);

// negation

expect(1).not().toBe(2);

Expects that the actual value is not undefined or null.

Expects that the actual value is equal to the expected value.

Expects that the actual value is equal to the expected value.

Expects that the actual value is strictly equal to the expected value.

Expects that the actual value is of the same type as the expected value.

Expects that the actual value is truthy.

Expects that the actual value is falsy.

Expects that the actual value is greater than the expected value.

Expects that the actual value is less than the expected value.

Expects that the actual value is close to the expected value.

Expects that the actual value is an instance of the expected value.

Expects that the actual value is one of the expected values.

Expects that the actual value is between the expected values.

Expects that the actual value is less than or equal to the expected value.

Expects that the actual value is greater than or equal to the expected value.

Expects that the actual value throws an error.

Expects that the actual value is null.

Expects that the actual value is undefined.

Expects that the actual value is NaN.

Expects that the actual value is defined.

Expects that the actual value is finite.

Expects that the actual value is positive.

Expects that the actual value is negative.

Expects that the actual value is zero.

Expects that the actual value is greater than zero.

Expects that the actual value is less than zero.

Expects that the actual value is positive infinity.

Expects that the actual value is negative infinity.

Expects that the actual value contains the expected value.

Expects that the actual value throws the expected value.

Expects that the actual value has returned the expected value.

Expects that the actual value has returned the expected value.

Expects that the actual value has last returned the expected value.

Expects that the actual value has the expected length.

Expects that the actual value matches the expected value.