Skip to content

Releases: iambumblehead/esmock

huge esmock.d.ts upgrade

29 Sep 04:05
28cbda5
Compare
Choose a tag to compare

This release dramatically improves the esmock.d.ts file, thanks to @jsejcksn,

install size down to 20.3kB

25 Sep 05:15
b7b908f
Compare
Choose a tag to compare

Numerous micro-optimisations in this release,

add jest using ts test example

22 Sep 02:34
60b47cc
Compare
Choose a tag to compare

This release mostly adds a typescript with jest test example (using jest-light-runner). Thank you for your help here nicolo-ribaudo/jest-light-runner#1 Also, a few simplifications were made and behaviour is unchanged,

minor changes, slightly smaller

15 Sep 07:16
01cdbfe
Compare
Choose a tag to compare

Low-risk release mostly fixing a json syntax error found in the README,

use partial mocking by default

06 Sep 15:55
302ca82
Compare
Choose a tag to compare

This 2.0.0 release includes changes incompatible with previous releases. A migration guide is included just below this small changelog list,


migration guide v1.9.8 => v2.0.0

  • change esmock.px(...args) to esmock(...args). "px" or "partial mocking" behaviour is the default behaviour in the new version
  • change { isPackageNotFoundError: false } to { isModuleNotFoundError: false } this option is renamed to be more accurate
  • to use "partial mocking" automatically, continue using esmock(...args)
  • to avoid "partial mocking" and to continue using "strict mocking" (explained below), use one of the following changes,
    • change import esmock from 'esmock' to import { strict as esmock } from 'esmock', or
    • change esmock(...args) to esmock.strict(...args)

The new version of esmock uses "partial mocking" by default which merges mock definitions with original module definitions. Previous versions used "strict mocking", where mock definitions are not modified or merged with original module definitions. Strict mocking is still available through esmock.strict and import { strict } from 'esmock'.

To demonstrate the difference, a target module and its usage with esmock,

import p from 'path'

console.log(p.dirname('/dog.png'), p.basename('./dog.png'))
import esmock, { strict } from 'esmock'

esmock('./logpath.js', { path: { basename: () => 'cat.png' } })
// "/ cat.png"

strict('./logpath.js', { path: { basename: () => 'cat.png' } })
// Error "The requested module 'path' does not provide an export named 'dirname'"

Examples of both default and strict mocking use "path" definitions that define "basename" only and not "dirname". The regular, "partial mocking" behaviour merges the mocked "path" definition with the core "path" definition, including "path.dirname". The "strict mocking" behaviour does not modify the mock definition and "dirname" is never defined, resulting in a runtime error.

maintenance and stability updates

28 Aug 19:51
ee7749f
Compare
Choose a tag to compare

This release consolidates many small contributions and changes accumulated over the previous three to four weeks. Some new features are yet to be documented, such as parenturl and isPackageNotFoundError,

support mocking modules not found in filesystem

25 Aug 08:51
968b357
Compare
Choose a tag to compare

support mocking specifiers that aren't found in filesystem re #126,

use isPackageNotFoundError: false to enable this. For example,

const component = await esmock(`../local/vueComponent.js`, {
  vue: { // vue was not downloaded and is not found in the filesystem
    h: (...args) => args
  }
}, {}, {
  isPackageNotFoundError: false
})

the interface for this may change in the near future

much improved support for esm design language patterns

23 Aug 08:52
5d9dce2
Compare
Choose a tag to compare

This release greatly improves esmock's parsing of esm design language patterns

support packages defining package.main dir only, cjs

19 Aug 15:36
b6a1bde
Compare
Choose a tag to compare

support node: prefixed core modules

15 Aug 15:51
4c2fc42
Compare
Choose a tag to compare