0.47.0 • Published 8 months ago

@olton/easytest v0.47.0

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

EasyTest

Simple testing framework for JavaScript and TypeScript, written in pure JavaScript.


Documentation: https://easy.org.ua/


Core features:

  • No need to import it, test, describe or ecpext in your test file. These functions are available globally.
  • You can use both js and ts test files in the same project.
  • Asynchronous code testing.
  • TypeScript testing out of the box.
  • Global DOM object for testing HTML objects.
  • Built-in coverage tool.
  • Verbose or non verbose mode.
  • Mock functions.
  • Big set of built-in matchers.
  • Extend expect function with your own matchers.
  • Compatible with codecov report viewer.
  • A lot of expects in one test case.
  • Setup and Teardown functions (beforeEach, afterEach, beforeAll, afterAll).

Support for PayPal to serhii@pimenov.com.ua


NPM Version License: MIT codecov NPM Downloads

Installation

npm install @olton/easytest -D

Usage

To use EasyTest you don't need to import it, test or describe in your test file. Create a test file with *.test.js or *.test.ts extension (for example). You can use both of them in the same project.

function hello() {
    return "Hello"
}

describe(`Common tests suite`, () => {
    it(`says hello`, () => {
        return expect(hello()).toBe("Hello")
    })
})

test(`Bad test 2 !== 1`, () => {
    return expect(2).toBe(1)
})

Async tests

async function fetchData() {
    return new Promise((resolve) => {
        setTimeout(() => {
            resolve("Data received");
        }, 1000);
    });
}

describe('Async function tests', async () => {
    it('should return data after 1 second', async () => {
        const data = await fetchData();
        return expect(data).toBe("Bad Data");
    });
});

Update package.json to run tests with easytest command.

{
    "scripts": {
        "test": "easytest"
    }
}

Functions

  • describe - create test suite
  • it - create a test case
  • test - create simple test
  • expect - create assertion
  • beforeEach - run before each test case
  • afterEach - run after each test case
  • beforeAll - run before all test cases
  • afterAll - run after all test cases
  • mock - create mock function

Matchers

EasyTest contains a big set of built-in matchers:

  • A simple comparison
  • A strong comparison
  • Type checking
  • Number checking
  • String checking
  • Array checking
  • Object checking
  • Color checking
  • IP, Email, Url checking
  • JSON, XML checking
  • Date, RegExp, Symbol checking
  • Function checking
  • HTML element checking
  • and more...

TypeScript

To use EasyTest with TypeScript you need to install tsx package.

npm install -D tsx cross-env

and then

{
    "scripts": {
        "test": "cross-env NODE_OPTIONS=\"--import tsx\" easytest"
    }
}

License

EasyTest licensed under MIT license.

Contributing

Bug Reports & Feature Requests

Use issue tracker to report bugs or request new features.


Copyright

© 2024-2025 Serhii Pimenov. All rights reserved.

0.41.1

8 months ago

0.43.0

8 months ago

0.46.0

8 months ago

0.44.0

8 months ago

0.42.0

8 months ago

0.40.0

11 months ago

0.47.0

8 months ago

0.45.0

8 months ago

0.39.0

1 year ago

0.38.0

1 year ago

0.37.0

1 year ago

0.36.0

1 year ago

0.35.0

1 year ago

0.34.0

1 year ago

0.33.0

1 year ago

0.32.0

1 year ago

0.31.0

1 year ago

0.30.0

1 year ago

0.29.0

1 year ago

0.28.0

1 year ago

0.27.0

1 year ago

0.26.0

1 year ago

0.25.0

1 year ago

0.24.0

1 year ago

0.23.0

1 year ago

0.22.0

1 year ago

0.21.0

1 year ago

0.20.0

1 year ago

0.19.0

1 year ago

0.18.0

1 year ago

0.17.0

1 year ago

0.16.0

1 year ago

0.15.0

1 year ago

0.14.0

1 year ago

0.13.0

1 year ago

0.12.0

1 year ago

0.11.0

1 year ago

0.10.0

1 year ago

0.9.0

1 year ago

0.8.0

1 year ago

0.7.0

1 year ago

0.6.0

1 year ago

0.5.0

1 year ago

0.4.0

1 year ago

0.3.0

1 year ago

0.2.0

1 year ago

0.1.0

1 year ago