l2beat / earl

☕ Ergonomic, modern and type-safe assertion library for TypeScript
https://earl.fun/
MIT License
257 stars 19 forks source link
assert assertion-libraries chai jest mocha testing typescript

Earl

Ergonomic, modern and type-safe assertion library for TypeScript

Brings good parts of Jest back to good ol' Mocha

Build status Software License

Features

Installation

npm install --save-dev earl

Example

import { expect } from 'earl'

const user = {
  name: 'John Doe',
  email: 'john@doe.com',
  notificationCount: 5,
}

// This code fails to compile, and TypeScript provides this useful
// error message:
// Property 'notificationCount' is missing in type
// '{ name: string; email: any; }' but required in type 'User'.
expect(user).toEqual({
  name: 'John Doe',
  email: expect.a(String),
})

Docs

License

Published under the MIT License. Copyright © 2023 L2BEAT.