Releases: l2beat/earl
earl@1.2.0
earl@1.1.0
Minor Changes
- 3a60d1f: Add toHaveSubset validator
earl@1.0.1
Patch Changes
- 2886d70: Fix esm exports
earl@1.0.0
Major Changes
-
54b295f: Earl 1.0.0
This is the first stable release of Earl. It is an almost complete rewrite of the original Earl. The new version is much simpler, more powerful and easier to use.
Changes from the previous version
-
The package name has changed from
earljs
toearl
. The old package name will be deprecated on npm.- The new release includes both CommonJS and ESM builds.
-
Website updates
-
The website domain name has changed from
https://earljs.dev
tohttps://earl.fun
. -
The old domain will keep redirecting to the new one for a while.
-
The documentation has been updated to include new guides, more examples.
-
The documentation engine changed from Docusaurus to Vitepress.
-
-
Snapshot testing no longer relies on
jest-snapshot
.-
We developed a custom implementation which is much simpler and easier to maintain.
-
Snapshots are now saved alongside test files inside
.snapshot
files. -
The
toMatchSnapshot
validator now requires a test context to be passed to it. This is done by passingthis
in mocha andctx
in uvu. -
Test runner integration namely
earljs/mocha
andearljs/uvu
are no longer needed and have been removed.
-
-
Extending Earl with custom matchers and validators is now much easier. Instead of a special plugin system, custom matchers and validators are defined in the same way as the built in ones.
-
Adding validators is now done using
registerValidator
and declaring module overrides to make types work. -
Adding matchers is now done using
registerMatcher
and declaring module overrides to make types work. -
The ability to add custom equality rules was removed and there are no plans to bring it back in the future.
-
A special export
earljs/internal
is no longer needed and has been removed.
-
-
Validator API changes
-
The
expect()
function now only takes a single argument, which is the value to be tested. No custom options can be passed to it. -
toBeAContainerWith
has been replaced bytoInclude
. -
toBeAnArrayOfLength
has been replaced bytoHaveLength
. -
toBeAnArrayWith
has been replaced bytoInclude
. -
toBeAnObjectWith
has been removed. We are planning to add a newtoHaveSubset
validator in the near future. -
toBeDefined
was removed. It was unintuitive that it checked bothnull
andundefined
. Instead you should now callexpect(value).not.toBeNullish()
. -
toBeExhausted
has replaced bytoHaveBeenExhausted
. -
toBeGreaterThan
now works with numbers and bigints. -
toBeGreaterThanOrEqualTo
has been replaced bytoBeGreaterThanOrEqual
and now works with numbers and bigints. -
toBeLessThan
now works with numbers and bigints. -
toBeLessThanOrEqualTo
has been replaced bytoBeLessThanOrEqual
and now works with numbers and bigints. -
toBeRejected
doesn't take arguments anymore. Instead you should usetoBeRejectedWith
to check the error. -
toEqual
no longer has type checking problems with recursive types. -
toHaveBeenCalledExactlyWith
has been removed. It was a very ugly API. It has been replaced by a suite of new mock validators. -
toMatchSnapshot
now requires a test context to be passed to it. This is done by passingthis
in mocha andctx
in uvu. -
toReferentiallyEqual
has been replaced bytoExactlyEqual
. -
toThrow
now always fails if the function returns a promise.
-
-
Matcher API changes
-
All matchers now return
never
instead of trying to imitate the type of the value they are matching. This behavior is going to stay until TypeScript introduces a better way to do this. -
arrayOfLength
has been replaced bylength
. -
arrayWith
has been replaced byincludes
. -
containerWith
has been replaced byincludes
. -
defined
now checks for onlyundefined
. Previously it checked for bothnull
andundefined
. Instead you should now callnotNullish
. -
numberCloseTo
has been replaced bycloseTo
. The second parameter is now just the delta and not an object with thedelta
property. -
numberGreaterThan
has been replaced bygreaterThan
and now works with numbers and bigints. -
numberGreaterThanOrEqualTo
has been replaced bygreaterThanOrEqual
and now works with numbers and bigints. -
numberLessThan
has been replaced bylessThan
and now works with numbers and bigints. -
numberLessThanOrEqualTo
has been replaced bylessThanOrEqual
and now works with numbers and bigints. -
objectWith
has been replaced bysubset
. -
stringMatching
has been replaced byincludes
andregex
.
-
-
Mock API changes
-
Fix types for mocks. Previously, the types for
.executes
and.executesOnce
were incorrect. -
Rename
Mock
toMockFunction
. -
Rename
MockOf
toMockFunctionOf
. -
Calling configuration functions that change the default mock behavior no longer resets the mock. An explicit
reset
function has been added for that purpose.
-
New features
-
New validators
-
toBeAnInteger
. -
toBeASafeInteger
. -
toBeBetween
. -
toBeCloseTo
. -
toBeEmpty
. -
toEqualUnsorted
. -
toHaveBeenCalled
. -
toHaveBeenCalledTimes
. -
toHaveBeenLastCalledWith
. -
toHaveBeenNthCalledWith
. -
toHaveBeenOnlyCalledWith
. -
toMatchRegex
. -
toMatchSchema
. -
toSatisfy
.
-
-
New matchers
-
between
. -
closeTo
. -
empty
. -
integer
. -
notEmpty
. -
notNullish
. -
property
. -
regex
. -
safeInteger
. -
satisfies
. -
schema
. -
subset
.
-
-
New mock capabilities
- Added
mockObject
that can be used to mock objects.
- Added
-
earljs@0.2.3
Patch Changes
-
1887ac2: Snapshot tests in
uvu
are now supported withearljs/uvu
.To use Earl with
uvu
, requireearljs/uvu
in your test command:# using the uvu cli $ uvu -r earljs/uvu tests # using node directly $ node -r earljs/uvu tests/example.test.js
earljs@0.2.2
Patch Changes
- fde9d67: Fixed "a" matcher for functions
earljs@0.2.1
Patch Changes
- 7378e50: Earl formatting no longer crashes on object with constructor set to undefined.
earljs@0.2.0
earljs@0.1.12
Patch Changes
- afbd34b: Ensure that package is published with the readme. Readme updates.
earljs@0.1.11
Patch Changes
- d69576f: Fix types for mockFn's default implementation
- 00cae63: Function mocks can now be typed as Mock.Of
- a0f7b98: Improve support for comparing recursive objects
- 3651e17: Earl no longer crashes in mocha --watch mode
- d02b7d6: process.env.UPDATE_SNAPSHOTS set to "1" is now treated the same as when set to "true"