Skip to content
/ latte Public

Latte - Framework for testing JavaScript/TypeScript with DOM and React support and built-in headless browser!

License

Notifications You must be signed in to change notification settings

olton/latte

Repository files navigation

🥛 Latte

Latte (an abbreviation from laconic testing) is a testing framework for JavaScript and TypeScript, written in pure JavaScript.


It is designed to be straightforward to use, with a focus on speed, performance, and user information.

Latte is an alternative to other testing frameworks like Jest, Mocha, and Jasmine with the following features:

  • Built-in DOM support
  • Built-in headless browser
  • Testing HTML elements
  • Testing React components
  • Testing Vue components (in development)
  • Testing Angular components (in development)

Documentation: https://latte.org.ua/

Demo


Core features:

  • Config free. No need to create any config files, but you can create latte.json file to set up your own configuration.
  • No need to import it, test, describe or expect in your test file. These functions are available globally.
  • Built-in headless browser in scope B and DOM support with option --dom (you have access to global DOM objects).
  • You can use both js and ts test files in the same project.
  • React Components testing (jsx syntax supported).
  • Asynchronous code testing.
  • TypeScript testing out of the box.
  • Mock functions.
  • Big set of built-in matchers.
  • Extend expect function with your own matchers.
  • A lot of expects in one test case.
  • Setup and Teardown functions (beforeEach, afterEach, beforeAll, afterAll).
  • Built-in coverage tool.
  • Verbose or non verbose mode.
  • Watching mode.
  • Different Reporters: lcov, console, html, and junit.
  • Open source and MIT license.

Support for PayPal to [email protected]


NPM Version License: MIT NPM Downloads

Installation

npm install @olton/latte -D

Usage

To use Latte you don't need to import it, test, describe or expect in your test file. All these functions are available globally.

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

You can test async code with async/await syntax.

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 latte command.

{
    "scripts": {
        "test": "latte"
    }
}

Functions

  • describe – create a test suite
  • it - create a test case in suite
  • test - create standalone 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

Latte 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 Latte with TypeScript you need to install tsx package.

npm install -D tsx cross-env

and then

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

License

Latte licensed under MIT license.

Contributing

Bug Reports & Feature Requests

Use issue tracker to report bugs or request new features.


Copyright

© 2025 Serhii Pimenov. All rights reserved.

About

Latte - Framework for testing JavaScript/TypeScript with DOM and React support and built-in headless browser!

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published