iambumblehead/esmock
### [`v2.0.0`](https://togithub.com/iambumblehead/esmock/releases/tag/v2.0.0)
[Compare Source](https://togithub.com/iambumblehead/esmock/compare/v1.9.8...v2.0.0)
This 2.0.0 release includes changes incompatible with previous releases. A migration guide is included just below this small changelog list,
- [exports a "strict mocking"](https://togithub.com/iambumblehead/esmock/pull/140) version of esmock
- [uses "partial mocking" behaviour with default export](https://togithub.com/iambumblehead/esmock/pull/141) and updates the readme,
- resolves error when partial mocking modules not found on filesystem
- renames option `isPackageNotFoundError` to `isModuleNotFoundError`
- [see the release announcement](https://togithub.com/iambumblehead/esmock/releases/tag/v2.0.0) for details and
***
##### 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,
```javascript
import p from 'path'
console.log(p.dirname('/dog.png'), p.basename('./dog.png'))
```
```javascript
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.
Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
[ ] If you want to rebase/retry this PR, click this checkbox.
This PR has been generated by Mend Renovate. View repository job log here.
This PR contains the following updates:
1.9.8
->2.0.0
Release Notes
iambumblehead/esmock
### [`v2.0.0`](https://togithub.com/iambumblehead/esmock/releases/tag/v2.0.0) [Compare Source](https://togithub.com/iambumblehead/esmock/compare/v1.9.8...v2.0.0) This 2.0.0 release includes changes incompatible with previous releases. A migration guide is included just below this small changelog list, - [exports a "strict mocking"](https://togithub.com/iambumblehead/esmock/pull/140) version of esmock - [uses "partial mocking" behaviour with default export](https://togithub.com/iambumblehead/esmock/pull/141) and updates the readme, - resolves error when partial mocking modules not found on filesystem - renames option `isPackageNotFoundError` to `isModuleNotFoundError` - [see the release announcement](https://togithub.com/iambumblehead/esmock/releases/tag/v2.0.0) for details and *** ##### 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, ```javascript import p from 'path' console.log(p.dirname('/dog.png'), p.basename('./dog.png')) ``` ```javascript 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.Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR has been generated by Mend Renovate. View repository job log here.